Some systems have same executable running multiple times, executed
with different command line arguments. These may be difficult to
distinguish from each other if we don't see also the arguments.
Show the whole argument list for each processes as this usually what
we want to see.
Signed-off-by: Timo Kokkonen <timo.t.kokkonen@iki.fi>
{
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;
}