]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
tests: use pgrep instead of ps --ppid ...
authorRuediger Meier <rudi@freebsd.ga-group.nl>
Mon, 17 Apr 2017 21:45:30 +0000 (23:45 +0200)
committerRuediger Meier <ruediger.meier@ga-group.nl>
Fri, 16 Feb 2018 10:20:42 +0000 (11:20 +0100)
The usage looks a bit cleaner, and I guess that pgrep(1) is available
on the same machines where "ps --ppid" would work (procps-ng).

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
tests/ts/misc/flock

index cf3ca535784c6c201bc10e4b1b07d025170c29ed..6a43fea40d59c76d2495ff117857e12b93195eb0 100755 (executable)
@@ -19,12 +19,9 @@ TS_DESC="flock"
 ts_init "$*"
 
 ts_check_test_command "$TS_CMD_FLOCK"
-ts_check_prog "ps"
+ts_check_prog "pgrep"
 ts_check_prog "timeout"
 
-if ! ps --ppid $$ &>/dev/null; then
-       ts_skip "no ps --ppid"
-fi
 
 function do_lock {
        local opts="$1"
@@ -58,7 +55,7 @@ if [ "$pid" -le "0" ] || ! kill -s 0 "$pid" &>/dev/null; then
        ts_die "unable to run flock"
 fi
 # the lock should be established when flock has a child
-timeout 1s bash -c "while [ \$(ps --ppid $pid |wc -l) -lt 2 ]; do sleep 0.1 ;done" \
+timeout 1s bash -c "while ! pgrep -P $pid >/dev/null; do sleep 0.1 ;done" \
        || ts_die "timeout waiting for flock child"
 
 ts_init_subtest "non-block"