FreeBSD Bugzilla – Attachment 61785 Details for
Bug 92523
allow rc scripts to kill process after a timeout
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
patch-rc.subr
patch-rc.subr (text/plain), 1.46 KB, created by
mitsururike
on 2012-11-30 09:48:08 UTC
(
hide
)
Description:
patch-rc.subr
Filename:
MIME Type:
Creator:
mitsururike
Created:
2012-11-30 09:48:08 UTC
Size:
1.46 KB
patch
obsolete
>--- rc.subr.orig 2012-11-30 17:29:49.000000000 +0900 >+++ rc.subr 2012-11-30 18:32:36.000000000 +0900 >@@ -398,6 +398,42 @@ > } > > # >+# wait_max_for_pids timeout pid [pid ...] >+# spins until none of the pids exist, or until a maximum of >+# "timeout" seconds have elapsed (whichever comes first). >+# >+wait_max_for_pids() >+{ >+ _timeout=$1 >+ shift >+ _list="$@" >+ if [ -z "$_list" ]; then >+ return 0 >+ fi >+ _prefix= >+ while [ $_timeout -gt 0 ] ; do >+ _nlist=""; >+ for _j in $_list; do >+ if kill -0 $_j 2>/dev/null; then >+ _nlist="${_nlist}${_nlist:+ }$_j" >+ fi >+ done >+ if [ -z "$_nlist" ]; then >+ return 0 >+ fi >+ _list=$_nlist >+ echo -n ${_prefix:-"Waiting (max $_timeout secs) for PIDS: "}$_list >+ _prefix=", " >+ sleep 2 >+ _timeout=$(($_timeout-2)) >+ done >+ if [ -n "$_prefix" ]; then >+ echo "." >+ fi >+ return 1 >+} >+ >+# > # run_rc_command argument > # Search for argument in the list of supported commands, which is: > # "start stop restart rcvar status poll ${extra_commands}" >@@ -757,8 +793,18 @@ > _run_rc_doit "$_doit" || return 1 > > # wait for the command to exit, >+ # kill it if a timeout is specified, > # and run postcmd. >- wait_for_pids $rc_pid >+ eval _timeout=\$${name}_stop_timeout >+ if [ -z $_timeout ]; then >+ eval _timeout=$default_stop_timeout >+ fi >+ if [ ${_timeout:-0} -gt 0 ]; then >+ wait_max_for_pids ${_timeout} $rc_pid || \ >+ echo kill -KILL $rc_pid >+ else >+ wait_for_pids $rc_pid >+ fi > > _run_rc_postcmd > ;;
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 92523
: 61785