xref: /freebsd/bin/pkill/tests/pgrep-_lf_test.sh (revision f126890ac5386406dadf7c4cfa9566cbb56537c5)
1#!/bin/sh
2
3base=`basename $0`
4
5echo "1..2"
6
7name="pgrep -LF <pidfile>"
8pidfile=$(pwd)/pidfile.txt
9sleep=$(pwd)/sleep.txt
10ln -sf /bin/sleep $sleep
11daemon -p $pidfile $sleep 5
12sleep 0.3
13chpid=`cat $pidfile`
14pid=`pgrep -f -L -F $pidfile $sleep`
15if [ "$pid" = "$chpid" ]; then
16	echo "ok 1 - $name"
17else
18	echo "not ok 1 - $name"
19fi
20kill "$chpid"
21
22# Be sure we cannot find process which pidfile is not locked.
23$sleep 5 &
24sleep 0.3
25chpid=$!
26echo $chpid > $pidfile
27pgrep -f -L -F $pidfile $sleep 2>/dev/null
28ec=$?
29case $ec in
300)
31	echo "not ok 2 - $name"
32	;;
33*)
34	echo "ok 2 - $name"
35	;;
36esac
37
38kill "$chpid"
39rm -f $pidfile
40rm -f $sleep
41