aboutsummaryrefslogtreecommitdiff
path: root/toys
diff options
context:
space:
mode:
Diffstat (limited to 'toys')
-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) {