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

Return to bug 107492