Path: blob/main/bin/pkill/tests/pgrep-_lf_test.sh
104523 views
#!/bin/sh12base=`basename $0`34echo "1..2"56name="pgrep -LF <pidfile>"7pidfile=$(pwd)/pidfile.txt8sleep=$(pwd)/sleep.txt9ln -sf /bin/sleep $sleep10daemon -p $pidfile $sleep 511sleep 0.312chpid=`cat $pidfile`13pid=`pgrep -f -L -F $pidfile $sleep`14if [ "$pid" = "$chpid" ]; then15echo "ok 1 - $name"16else17echo "not ok 1 - $name"18fi19kill "$chpid"2021# Be sure we cannot find process which pidfile is not locked.22$sleep 5 &23sleep 0.324chpid=$!25echo $chpid > $pidfile26pgrep -f -L -F $pidfile $sleep 2>/dev/null27ec=$?28case $ec in290)30echo "not ok 2 - $name"31;;32*)33echo "ok 2 - $name"34;;35esac3637kill "$chpid"38rm -f $pidfile39rm -f $sleep404142