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