diff options
author | Antoine Jacoutot <ajacoutot@cvs.openbsd.org> | 2021-11-07 08:26:13 +0000 |
---|---|---|
committer | Antoine Jacoutot <ajacoutot@cvs.openbsd.org> | 2021-11-07 08:26:13 +0000 |
commit | 75091232f0dbad305093dd6fd43dcc4858434c68 (patch) | |
tree | 3afaa7921ae4fb7107686aecf816dcc08fbdae80 /etc/rc.d | |
parent | cacf48b5de724551049cefce09a8a507eb9cbe79 (diff) |
Use built-in SECONDS instead of hand roller timer.
with a tweak from kn@
ok sthen@
Diffstat (limited to 'etc/rc.d')
-rw-r--r-- | etc/rc.d/rc.subr | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/etc/rc.d/rc.subr b/etc/rc.d/rc.subr index eeb34d99333..7809a1b4d21 100644 --- a/etc/rc.d/rc.subr +++ b/etc/rc.d/rc.subr @@ -1,4 +1,4 @@ -# $OpenBSD: rc.subr,v 1.140 2021/11/06 13:33:10 ajacoutot Exp $ +# $OpenBSD: rc.subr,v 1.141 2021/11/07 08:26:12 ajacoutot Exp $ # # Copyright (c) 2010, 2011, 2014-2021 Antoine Jacoutot <ajacoutot@openbsd.org> # Copyright (c) 2010, 2011 Ingo Schwarze <schwarze@openbsd.org> @@ -149,20 +149,18 @@ _rc_sendsig() { } _rc_wait() { - local _i=0 if [ X"$1" = X"start" ]; then # prevent hanging the boot sequence trap "_rc_alarm" ALRM - while [ $_i -lt ${daemon_timeout} ]; do + while (( SECONDS < daemon_timeout )); do if _rc_do rc_check; then [ X"${rc_bg}" = X"YES" ] || [ -z "$$" ] && break fi sleep 1 - _i=$((_i+1)) done & wait pkill -ALRM -P $$ return fi - while [ $_i -lt ${daemon_timeout} ]; do + while (( SECONDS < daemon_timeout )); do case "$1" in reload) _rc_do rc_check && return 0 ;; @@ -172,13 +170,12 @@ _rc_wait() { # or a non-default rc_stop() function; do it 2s before # timeout to re-enter the loop one last time which will # give 1s for SIGTERM to terminate the process - ((_i == daemon_timeout-2)) && _rc_do _rc_sendsig TERM + ((SECONDS == daemon_timeout-2)) && _rc_do _rc_sendsig TERM _rc_do rc_check || return 0 ;; *) break ;; esac sleep 1 - _i=$((_i+1)) done # KILL the process |