]> CyberLeo.Net >> Repos - FreeBSD/releng/9.2.git/blob - tools/regression/usr.bin/pkill/pgrep-LF.t
- Copy stable/9 to releng/9.2 as part of the 9.2-RELEASE cycle.
[FreeBSD/releng/9.2.git] / tools / regression / usr.bin / pkill / pgrep-LF.t
1 #!/bin/sh
2 # $FreeBSD$
3
4 base=`basename $0`
5
6 echo "1..2"
7
8 name="pgrep -LF <pidfile>"
9 pidfile=`mktemp /tmp/$base.XXXXXX` || exit 1
10 sleep=`mktemp /tmp/$base.XXXXXX` || exit 1
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