top/ps: argv0:"gdm-session-worker [pam/gdm-password]" == comm:"gdm-session-wor"
authorDenys Vlasenko <vda.linux@googlemail.com>
Tue, 2 Oct 2012 09:31:37 +0000 (11:31 +0200)
committerDenys Vlasenko <vda.linux@googlemail.com>
Tue, 2 Oct 2012 09:31:37 +0000 (11:31 +0200)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
libbb/procps.c

index 295048c4660e476a43dfc77e464f4851e88b530d..b4557e797616510ceef61981a074eafc338378cb 100644 (file)
@@ -583,6 +583,8 @@ void FAST_FUNC read_cmdline(char *buf, int col, unsigned pid, const char *comm)
                buf[sz] = '\0';
                while (--sz >= 0 && buf[sz] == '\0')
                        continue;
+               /* Prevent basename("process foo/bar") = "bar" */
+               strchrnul(buf, ' ')[0] = '\0';
                base = bb_basename(buf); /* before we replace argv0's NUL with space */
                while (sz >= 0) {
                        if ((unsigned char)(buf[sz]) < ' ')