summaryrefslogtreecommitdiffstats
path: root/tests/ts/misc
diff options
context:
space:
mode:
authorRuediger Meier2017-04-17 23:45:30 +0200
committerRuediger Meier2018-02-16 11:20:42 +0100
commit7eb1320bf73c10533237344287f96a4f8ad61573 (patch)
tree1e943f41e107e71d5518ddf03d9df1f2e442fc77 /tests/ts/misc
parentmisc: fix typos using codespell (diff)
downloadkernel-qcow2-util-linux-7eb1320bf73c10533237344287f96a4f8ad61573.tar.gz
kernel-qcow2-util-linux-7eb1320bf73c10533237344287f96a4f8ad61573.tar.xz
kernel-qcow2-util-linux-7eb1320bf73c10533237344287f96a4f8ad61573.zip
tests: use pgrep instead of ps --ppid ...
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>
Diffstat (limited to 'tests/ts/misc')
-rwxr-xr-xtests/ts/misc/flock7
1 files changed, 2 insertions, 5 deletions
diff --git a/tests/ts/misc/flock b/tests/ts/misc/flock
index cf3ca5357..6a43fea40 100755
--- a/tests/ts/misc/flock
+++ b/tests/ts/misc/flock
@@ -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"