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