aboutsummaryrefslogtreecommitdiff
path: root/libbb/procps.c
diff options
context:
space:
mode:
Diffstat (limited to 'libbb/procps.c')
-rw-r--r--libbb/procps.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/libbb/procps.c b/libbb/procps.c
index 5a4ea59d0..452b50b82 100644
--- a/libbb/procps.c
+++ b/libbb/procps.c
@@ -589,12 +589,14 @@ void FAST_FUNC read_cmdline(char *buf, int col, unsigned pid, const char *comm)
589 buf[sz] = ' '; 589 buf[sz] = ' ';
590 sz--; 590 sz--;
591 } 591 }
592 if (base[0] == '-') /* "-sh" (login shell)? */
593 base++;
592 594
593 /* If comm differs from argv0, prepend "{comm} ". 595 /* If comm differs from argv0, prepend "{comm} ".
594 * It allows to see thread names set by prctl(PR_SET_NAME). 596 * It allows to see thread names set by prctl(PR_SET_NAME).
595 */ 597 */
596 if (base[0] == '-') /* "-sh" (login shell)? */ 598 if (!comm)
597 base++; 599 return;
598 comm_len = strlen(comm); 600 comm_len = strlen(comm);
599 /* Why compare up to comm_len, not COMM_LEN-1? 601 /* Why compare up to comm_len, not COMM_LEN-1?
600 * Well, some processes rewrite argv, and use _spaces_ there 602 * Well, some processes rewrite argv, and use _spaces_ there
@@ -613,7 +615,7 @@ void FAST_FUNC read_cmdline(char *buf, int col, unsigned pid, const char *comm)
613 buf[col - 1] = '\0'; 615 buf[col - 1] = '\0';
614 } 616 }
615 } else { 617 } else {
616 snprintf(buf, col, "[%s]", comm); 618 snprintf(buf, col, "[%s]", comm ? comm : "?");
617 } 619 }
618} 620}
619 621