aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2016-02-29 10:34:07 -0800
committerRob Landley <rob@landley.net>2016-02-29 13:11:32 -0600
commit226c1cb1dc86e8545c0f05886149a07c40a88162 (patch)
tree68e28fb0d82961f872e067dbf12df8e7b1872943
parent1b3fd4a5dc3fb62a96fb3127070c5aca7cc2ee3e (diff)
downloadtoybox-226c1cb1dc86e8545c0f05886149a07c40a88162.tar.gz
Fix trailing spaces on ps -o cmdline.
-rw-r--r--toys/posix/ps.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/toys/posix/ps.c b/toys/posix/ps.c
index f99a2168..d2ef9fc1 100644
--- a/toys/posix/ps.c
+++ b/toys/posix/ps.c
@@ -673,7 +673,7 @@ static int get_ps(struct dirtree *new)
len = sizeof(toybuf)-(buf-toybuf)-260-256*(ARRAY_LEN(fetch)-j);
sprintf(buf, "%lld/%s", *slot, fetch[j].name);
- // For cmdline we readlink instead of read contents
+ // For exe we readlink instead of read contents
if (j==3) {
if ((len = readlinkat(fd, buf, buf, len))>0) buf[len] = 0;
else *buf = 0;
@@ -735,7 +735,8 @@ static int get_ps(struct dirtree *new)
if (buf[len-1]=='\n') buf[--len] = 0;
// Turn NUL to space, other low ascii to ? (in non-tty mode)
- for (i=0; i<len; i++) {
+ // cmdline has a trailing NUL that we don't want to turn to space.
+ for (i=0; i<len-1; i++) {
char c = buf[i];
if (!c) {