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