diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2015-10-24 03:45:57 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2015-10-24 03:45:57 +0200 |
commit | 049b007865e2dfcfd2093db732b3bfbcb75b5c77 (patch) | |
tree | 8fa3a2d3bbe96bdf5177ff9746aea7167a6a6538 /libbb | |
parent | 00da72bee09cfe4a757cbba4465a76269dae9f43 (diff) | |
download | busybox-w32-049b007865e2dfcfd2093db732b3bfbcb75b5c77.tar.gz busybox-w32-049b007865e2dfcfd2093db732b3bfbcb75b5c77.tar.bz2 busybox-w32-049b007865e2dfcfd2093db732b3bfbcb75b5c77.zip |
pmap: fix bogus {no such process} comm field text
function old new delta
read_cmdline 246 266 +20
procps_get_maps 196 193 -3
packed_usage 30413 30404 -9
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/2 up/down: 20/-12) Total: 8 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'libbb')
-rw-r--r-- | libbb/procps.c | 8 |
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 | ||