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