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 05eefe0da..4edc54d48 100644
--- a/libbb/procps.c
+++ b/libbb/procps.c
@@ -588,12 +588,14 @@ void FAST_FUNC read_cmdline(char *buf, int col, unsigned pid, const char *comm)
588 buf[sz] = ' '; 588 buf[sz] = ' ';
589 sz--; 589 sz--;
590 } 590 }
591 if (base[0] == '-') /* "-sh" (login shell)? */
592 base++;
591 593
592 /* If comm differs from argv0, prepend "{comm} ". 594 /* If comm differs from argv0, prepend "{comm} ".
593 * It allows to see thread names set by prctl(PR_SET_NAME). 595 * It allows to see thread names set by prctl(PR_SET_NAME).
594 */ 596 */
595 if (base[0] == '-') /* "-sh" (login shell)? */ 597 if (!comm)
596 base++; 598 return;
597 comm_len = strlen(comm); 599 comm_len = strlen(comm);
598 /* Why compare up to comm_len, not COMM_LEN-1? 600 /* Why compare up to comm_len, not COMM_LEN-1?
599 * Well, some processes rewrite argv, and use _spaces_ there 601 * Well, some processes rewrite argv, and use _spaces_ there
@@ -612,7 +614,7 @@ void FAST_FUNC read_cmdline(char *buf, int col, unsigned pid, const char *comm)
612 buf[col - 1] = '\0'; 614 buf[col - 1] = '\0';
613 } 615 }
614 } else { 616 } else {
615 snprintf(buf, col, "[%s]", comm); 617 snprintf(buf, col, "[%s]", comm ? comm : "?");
616 } 618 }
617} 619}
618 620