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>
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"
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"