/[baselayout]/branches/rc-scripts-1_6/net-scripts/net.modules.d/helpers.d/functions
Gentoo

Diff of /branches/rc-scripts-1_6/net-scripts/net.modules.d/helpers.d/functions

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 841 Revision 842
81# bool clean_pidfile(char *file) 81# bool clean_pidfile(char *file)
82# 82#
83# Removes the given pidfile if the process is not running 83# Removes the given pidfile if the process is not running
84# Returns 1 if the process is still running otherwise 0 84# Returns 1 if the process is still running otherwise 0
85clean_pidfile() { 85clean_pidfile() {
86 local pidfile=${1} cmd 86 local pidfile=${1}
87 87
88 [[ ! -f ${pidfile} ]] && return 0 88 [[ ! -f ${pidfile} ]] && return 0
89 local pid=$( cat ${pidfile} )
89 90
91 if [[ -n ${pid} ]]; then
90 cmd=${pidfile##*/} 92 local cmd=${pidfile##*/}
91 cmd=${cmd%%-*} 93 cmd=${cmd%%-*}
92 ps -p $( cat ${pidfile} 2>/dev/null ) | grep -q ${cmd} && return 1 94 ps -p ${pid} 2>/dev/null | grep -q ${cmd} && return 1
95 fi
93 96
94 rm -f ${pidfile} 97 rm -f ${pidfile}
95 return 0 98 return 0
96} 99}
97 100

Legend:
Removed from v.841  
changed lines
  Added in v.842

  ViewVC Help
Powered by ViewVC 1.1.20