Skip to content

Commit

Permalink
ps: exit with exit status 1 if no processes shown.
Browse files Browse the repository at this point in the history
This matches procps ps, and at least one LTP test relies on it. The
behavior is specifically "nothing matches", not "one PID didn't match":
assuming no process 666, `ps 666` exits with 1, but `ps 1 666` exits
with 0.
  • Loading branch information
enh-google authored and landley committed Aug 27, 2021
1 parent a2bf491 commit 366d5a9
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions toys/posix/ps.c
Original file line number Diff line number Diff line change
Expand Up @@ -1400,6 +1400,7 @@ void ps_main(void)
if (CFG_TOYBOX_FREE) free(tbsort);
}

if (!TT.kcount) toys.exitval = 1;
if (CFG_TOYBOX_FREE) {
free(TT.gg.ptr);
free(TT.GG.ptr);
Expand Down

0 comments on commit 366d5a9

Please sign in to comment.