From ed6c56c52885ad771e313394046ee5e2120af0ab Mon Sep 17 00:00:00 2001 From: ajacoutot Date: Thu, 11 Nov 2021 12:08:36 +0000 Subject: [PATCH] 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@ --- etc/rc.d/rc.subr | 9 +++++---- 1 file 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 # Copyright (c) 2010, 2011 Ingo Schwarze @@ -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 -- 2.20.1