]> TLD Linux GIT Repositories - rc-scripts.git/blob - t/status-pidfile.sh
- from PLD
[rc-scripts.git] / t / status-pidfile.sh
1 #!/bin/sh
2
3 # broken check with --pidfile specified:
4 #
5 # $ (. /etc/rc.d/init.d/functions; status --pidfile /var/run/naviagent/agent.pid naviagent)
6 # naviagent (pid 12788) is running...
7 #
8 # $ ls -l /proc/`cat /var/run/naviagent/agent.pid`
9 # ls: cannot access /proc/12788: No such file or directory
10
11 lib=$(dirname "$0")/..
12 tmp=$(mktemp -d)
13
14 # TODO: rc_cache_init should be able to use tmp dir, not real root
15 . $lib/lib/functions
16
17 # first unused pid
18 pid=9999999 # may not exist
19 procname=testd # irrelevant
20 pidfile=$tmp/agent.pid
21
22 if [ -d /proc/$pid ]; then
23         echo >&2 "bad pid chosen for test, /proc/$pid exists"
24         exit 1
25 fi
26
27 echo $pid > $pidfile
28 status --pidfile $pidfile $procname
29 rc=$?
30 if [ $rc = 0 ]; then
31         echo "FAIL: should not say process is running"
32         rv=1
33 else
34         echo "OK: process is not running"
35         rv=0
36 fi
37
38 rm -rf $tmp
39 exit $rv