diff options
author | Antoine Jacoutot <ajacoutot@cvs.openbsd.org> | 2021-11-11 12:08:37 +0000 |
---|---|---|
committer | Antoine Jacoutot <ajacoutot@cvs.openbsd.org> | 2021-11-11 12:08:37 +0000 |
commit | fe0cb41d6ba0a79ed494d0cf8234821a0c35152f (patch) | |
tree | e074b90664510fcf41987a15443a9f5aa1fc61fc /etc/rc.d | |
parent | bc96a0067f7bc6146dc3ed3279f2839238bc28d9 (diff) |
Run "_rc_wait stop" _before_ stopping the daemon and not after...
This doesn't change the default behavior but fixes rc.d scripts with a home made
rc_stop() function that can block and potentially hangs halt/reboot forever.
ok robert@
Diffstat (limited to 'etc/rc.d')
-rw-r--r-- | etc/rc.d/rc.subr | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/etc/rc.d/rc.subr b/etc/rc.d/rc.subr index 9172157f147..0d16649544c 100644 --- a/etc/rc.d/rc.subr +++ b/etc/rc.d/rc.subr @@ -1,4 +1,4 @@ -# $OpenBSD: rc.subr,v 1.145 2021/11/11 10:37:36 ajacoutot Exp $ +# $OpenBSD: rc.subr,v 1.146 2021/11/11 12:08:36 ajacoutot Exp $ # # Copyright (c) 2010, 2011, 2014-2021 Antoine Jacoutot <ajacoutot@openbsd.org> # Copyright (c) 2010, 2011 Ingo Schwarze <schwarze@openbsd.org> @@ -209,7 +209,7 @@ rc_stop() { } rc_cmd() { - local _exit _n _ret + local _exit _n _ret _timer [ -n "${1}" ] && echo "${_rc_actions}" | grep -qw -- ${1} || _rc_usage @@ -265,8 +265,9 @@ rc_cmd() { stop) _rc_do rc_check || exit 0 echo $_n "${INRC:+ }${_name}" - _rc_do rc_stop || _rc_exit failed - _rc_do _rc_wait stop || _exit=killed + _rc_do _rc_wait stop & _timer=$! + _rc_do rc_stop || { kill ${_timer}; _rc_exit failed; } + wait ${_timer} && _exit=ok || _exit=killed if type rc_post >/dev/null; then _rc_do rc_post || _exit=failed fi |