aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2016-09-28 11:00:30 -0700
committerRob Landley <rob@landley.net>2016-09-29 13:41:35 -0500
commit703c49e0cb9718b4bfad9fcee45329c972aab12e (patch)
treec0857571b5a5acf1a6b78f0b111a4d8cf5cf686a
parent2b66afffb8b51a4e68b508be1858dcde7706142e (diff)
downloadtoybox-703c49e0cb9718b4bfad9fcee45329c972aab12e.tar.gz
Accept extra ps arguments as additional pids.
POSIX says nothing, but traditional ps lets you say "ps 123" in addition to "ps -p 123". (You can mix and match too: "ps -p 123,124 666 667" works fine.) Bug: 31778761
-rw-r--r--toys/posix/ps.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/toys/posix/ps.c b/toys/posix/ps.c
index bb6bcbad..011a43e3 100644
--- a/toys/posix/ps.c
+++ b/toys/posix/ps.c
@@ -1151,6 +1151,7 @@ static void shared_main(void)
void ps_main(void)
{
+ char **arg;
struct dirtree *dt;
char *not_o;
int i;
@@ -1170,6 +1171,10 @@ void ps_main(void)
comma_args(TT.ps.k, &TT.kfields, "bad -k", parse_ko);
dlist_terminate(TT.kfields);
+ // It's undocumented, but traditionally extra arguments are extra -p args
+ for (arg = toys.optargs; *arg; arg++)
+ if (parse_rest(&TT.pp, *arg, strlen(*arg))) error_exit_raw(*arg);
+
// Figure out which fields to display
not_o = "%sTTY,TIME,CMD";
if (toys.optflags&FLAG_f)