/*
- * Copyright (C) 2010 Timo Kokkonen <kaapeli@itanic.dy.fi>
+ * Copyright (C) 2010 Timo Kokkonen <timo.t.kokkonen@iki.fi>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
{
FILE *file;
char path[512];
- int ret;
+ int ret, i;
snprintf(path, sizeof(path), "/proc/%d/task/%d/cmdline", pid, tid);
file = fopen(path, "rb");
cmdline[ret - 1] = 0;
fclose(file);
+ /*
+ * Process arguments are separated by NULL bytes. Replace
+ * these with spacese so that the arguments become visible
+ * too.
+ */
+ for (i = 0; i < ret - 1; i++)
+ if (cmdline[i] == '\0')
+ cmdline[i] = ' ';
+
return ret > 0 ? 0 : -1;
}