I don't know that anyone cares, but these failures made me think I'd
broken something while testing the -SIGNAL patch.

The -s parsing wasn't taking into account that -s 0 is a special case,
and the -o test was assuming that pkill can tell the difference between
two processes started at roughly the same time. Hopefully there's
higher-resolution data available that can avoid the need for yet another
sleep in the tests.
---
 tests/pkill.test | 1 +
 toys/posix/ps.c  | 2 ++
 2 files changed, 3 insertions(+)
From d3e783a0bfda5a95e86836f670358315ca04a033 Mon Sep 17 00:00:00 2001
From: Elliott Hughes <[email protected]>
Date: Mon, 23 May 2016 10:46:47 -0700
Subject: [PATCH] Fix remaining pkill tests.

I don't know that anyone cares, but these failures made me think I'd
broken something while testing the -SIGNAL patch.

The -s parsing wasn't taking into account that -s 0 is a special case,
and the -o test was assuming that pkill can tell the difference between
two processes started at roughly the same time. Hopefully there's
higher-resolution data available that can avoid the need for yet another
sleep in the tests.
---
 tests/pkill.test | 1 +
 toys/posix/ps.c  | 2 ++
 2 files changed, 3 insertions(+)

diff --git a/tests/pkill.test b/tests/pkill.test
index 7a20ae5..0bea32a 100755
--- a/tests/pkill.test
+++ b/tests/pkill.test
@@ -63,6 +63,7 @@ killall yes >/dev/null 2>&1
 
 yes >/dev/null &
 proc1=$!
+sleep 1
 yes >/dev/null &
 proc2=$!
 sleep 1
diff --git a/toys/posix/ps.c b/toys/posix/ps.c
index e5adc19..4f8d75a 100644
--- a/toys/posix/ps.c
+++ b/toys/posix/ps.c
@@ -980,6 +980,8 @@ static char *parse_rest(void *data, char *str, int len)
   if (isdigit(*str)) {
     ll[pl->len] = xstrtol(str, &end, 10);
     if (end==(len+str)) num++;
+    // For pkill, -s 0 represents pkill's session id.
+    if (pl==&TT.ss && ll[pl->len]==0) ll[pl->len] = getsid(0);
   }
 
   if (pl==&TT.pp || pl==&TT.ss) {
-- 
2.8.0.rc3.226.g39d4020

_______________________________________________
Toybox mailing list
[email protected]
http://lists.landley.net/listinfo.cgi/toybox-landley.net

Reply via email to