Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 107492 | Differences between
and this patch

Collapse All | Expand All

(-)rc-daemon.sh (-8 / +21 lines)
Lines 68-73 Link Here
68
			--pid=*)
68
			--pid=*)
69
				pidfile="${1##--pid=}"
69
				pidfile="${1##--pid=}"
70
				;;
70
				;;
71
#			--retry)
72
#				addvar="RC_RETRY_COUNT"
73
#				;;
71
			-s|--signal)
74
			-s|--signal)
72
				addvar="signal"
75
				addvar="signal"
73
				;;
76
				;;
Lines 128-150 Link Here
128
# via pkill
131
# via pkill
129
# Returns 0 if successfuly otherwise 1
132
# Returns 0 if successfuly otherwise 1
130
rc_try_kill_pid() {
133
rc_try_kill_pid() {
131
	local pid="$1" signal="${2:-TERM}" session="${3:-false}"  i s
134
	local pid="$1" signal="${2:-TERM}" session="${3:-false}" i s p e
132
135
133
	# We split RC_RETRY_TIMEOUT into tenths of seconds
136
	# We split RC_RETRY_TIMEOUT into tenths of seconds
134
	# So we return as fast as possible
137
	# So we return as fast as possible
135
	(( s=${RC_RETRY_TIMEOUT}/10 ))
138
	s=$( LC_ALL=C awk "BEGIN { print ${RC_RETRY_TIMEOUT}/10 }" )
136
139
137
	for (( i=0; i<RC_RETRY_COUNT*10; i++ )); do
140
	for (( i=0; i<RC_RETRY_COUNT*10; i++ )); do
138
		if ${session} ; then
141
		if ${session} ; then
139
			if [[ -x /usr/bin/pkill ]]; then
142
			if [[ -x /usr/bin/pkill ]]; then
140
				/usr/bin/pkill "-${signal}" -s "${pid}" || return 0
143
				pkill "-${signal}" -s "${pid}"
144
				pgrep -s "${pid}" >/dev/null || return 0
141
			else
145
			else
142
				local pids=$(/bin/ps -eo pid,sid | /bin/sed -n 's/'${pid}'$//p')
146
				local pids=$(ps -eo pid,sid | sed -n 's/'${pid}'$//p')
143
				[[ -z ${pids} ]] && return 0
147
				[[ -z ${pids} ]] && return 0
144
				/bin/kill -s "${signal}" ${pids} 2>/dev/null
148
				kill -s "${signal}" ${pids} 2>/dev/null
149
				e=false
150
				for p in ${pids}; do
151
					if [[ -d "/proc/${p}" ]]; then
152
						e=true
153
						break
154
					fi
155
				done
156
				${e} || return 0
145
			fi
157
			fi
146
		else
158
		else
147
			/bin/kill -s "${signal}" "${pid}" 2>/dev/null || return 0
159
			kill -s "${signal}" "${pid}" 2>/dev/null
160
			[[ ! -d "/proc/${pid}" ]] && return 0
148
		fi
161
		fi
149
		LC_ALL=C /bin/sleep "${s}"
162
		LC_ALL=C /bin/sleep "${s}"
150
	done
163
	done
Lines 267-278 Link Here
267
280
268
	for pid in ${pids}; do
281
	for pid in ${pids}; do
269
		if [[ ${RC_FAIL_ON_ZOMBIE} == "yes" ]]; then
282
		if [[ ${RC_FAIL_ON_ZOMBIE} == "yes" ]]; then
270
			/bin/ps -p "${pid}" &>/dev/null || return 1
283
			ps -p "${pid}" &>/dev/null || return 1
271
		fi
284
		fi
272
285
273
		if rc_kill_pid "${pid}" false ; then
286
		if rc_kill_pid "${pid}" false ; then
274
			# Remove the pidfile if the process didn't
287
			# Remove the pidfile if the process didn't
275
			[[ -f ${pidfile} ]] && /bin/rm -f "${pidfile}"
288
			[[ -f ${pidfile} ]] && rm -f "${pidfile}"
276
		else
289
		else
277
			retval=1
290
			retval=1
278
		fi
291
		fi

Return to bug 107492