File: functions

package info (click to toggle)
jabber-common 0.5
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 56 kB
  • ctags: 1
  • sloc: sh: 76; makefile: 47
file content (20 lines) | stat: -rw-r--r-- 544 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
check_pid() {
  # check for PID file
  if [ -f $PID ]; then
     # PID file is there, is it readable?
     if [ -r $PID ]; then
        # it's readable, is there a process?
        if [ "$DAEMON $CMDLINE" = "`ps -p\`cat $PID\` -o cmd h`" ]; then
           # looks like it's already running
           echo "$NAME is already running."
           exit 0
        else
           # looks like a stale PID file
           rm -f $PID
        fi
     else
        echo "$PID file already exists, but is not accessible."
        exit 1
     fi
  fi
}