summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--etc/rc.d/rc.subr36
-rw-r--r--etc/rc.d/ypbind3
-rw-r--r--share/man/man8/rc.d.89
-rw-r--r--share/man/man8/rc.subr.822
4 files changed, 36 insertions, 34 deletions
diff --git a/etc/rc.d/rc.subr b/etc/rc.d/rc.subr
index 12544734efa..3579c7d594d 100644
--- a/etc/rc.d/rc.subr
+++ b/etc/rc.d/rc.subr
@@ -1,6 +1,6 @@
-# $OpenBSD: rc.subr,v 1.118 2017/02/17 16:42:41 ajacoutot Exp $
+# $OpenBSD: rc.subr,v 1.119 2017/05/27 13:51:52 ajacoutot Exp $
#
-# Copyright (c) 2010, 2011, 2014-2016 Antoine Jacoutot <ajacoutot@openbsd.org>
+# Copyright (c) 2010, 2011, 2014-2017 Antoine Jacoutot <ajacoutot@openbsd.org>
# Copyright (c) 2010, 2011 Ingo Schwarze <schwarze@openbsd.org>
# Copyright (c) 2010, 2011, 2014 Robert Nagy <robert@openbsd.org>
#
@@ -79,11 +79,28 @@ _rc_exit() {
[ X"$1" = X"ok" ] && exit 0 || exit 1
}
+_rc_alarm()
+{
+ trap - ALRM
+ kill -ALRM ${_TIMERSUB} 2>/dev/null # timer may not be running anymore
+ kill $! 2>/dev/null # kill last job if it's running
+}
+
_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
+ _rc_do rc_check && break
+ sleep 1
+ _i=$((_i+1))
+ done & wait
+ pkill -ALRM -P $$
+ return
+ fi
while [ $_i -lt ${daemon_timeout} ]; do
case "$1" in
- reload|start)
+ reload)
_rc_do rc_check && return 0 ;;
stop)
_rc_do rc_check || return 0 ;;
@@ -150,7 +167,7 @@ _rc_parse_conf() {
[ -n "${FUNCS_ONLY}" ] && return
rc_start() {
- ${rcexec} "${daemon} ${daemon_flags} ${_bg}"
+ ${rcexec} "${daemon} ${daemon_flags}"
}
rc_check() {
@@ -166,7 +183,7 @@ rc_stop() {
}
rc_cmd() {
- local _bg _n
+ local _n _ret
[ -n "${1}" ] && echo "${_rc_actions}" | grep -qw -- ${1} || _rc_usage
@@ -179,7 +196,6 @@ rc_cmd() {
_rc_err "$0: $1 is not supported"
fi
- [ X"${rc_bg}" = X"YES" ] && _bg="&"
[ -n "${_RC_DEBUG}" ] || _n="-n"
_rc_do _rc_parse_conf ${_RC_RUNFILE}
@@ -200,8 +216,12 @@ rc_cmd() {
if type rc_pre >/dev/null; then
_rc_do rc_pre || break
fi
- _rc_do rc_start || break
- _rc_do _rc_wait start || break
+ _rc_do _rc_wait start & _TIMERSUB=$!
+ trap "_rc_alarm" ALRM
+ _rc_do rc_start; _ret=$?
+ kill -ALRM ${_TIMERSUB}
+ wait ${_TIMERSUB} 2>/dev/null # don't print Alarm clock
+ [[ "${_ret}" == @(0|142) ]] && _rc_do rc_check || break
_rc_do _rc_write_runfile
_rc_exit ok
done
diff --git a/etc/rc.d/ypbind b/etc/rc.d/ypbind
index 32bc81baff9..7c20bda3412 100644
--- a/etc/rc.d/ypbind
+++ b/etc/rc.d/ypbind
@@ -1,12 +1,11 @@
#!/bin/sh
#
-# $OpenBSD: ypbind,v 1.5 2015/10/18 03:51:11 deraadt Exp $
+# $OpenBSD: ypbind,v 1.6 2017/05/27 13:51:52 ajacoutot Exp $
daemon="/usr/sbin/ypbind"
. /etc/rc.d/rc.subr
-rc_bg=YES
rc_reload=NO
rc_pre() {
diff --git a/share/man/man8/rc.d.8 b/share/man/man8/rc.d.8
index 64576eff7f6..a9635344f4a 100644
--- a/share/man/man8/rc.d.8
+++ b/share/man/man8/rc.d.8
@@ -1,4 +1,4 @@
-.\" $OpenBSD: rc.d.8,v 1.32 2017/05/25 09:40:18 ajacoutot Exp $
+.\" $OpenBSD: rc.d.8,v 1.33 2017/05/27 13:51:52 ajacoutot Exp $
.\"
.\" Copyright (c) 2011 Robert Nagy, Antoine Jacoutot, Ingo Schwarze
.\" All rights reserved.
@@ -24,7 +24,7 @@
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd $Mdocdate: May 25 2017 $
+.Dd $Mdocdate: May 27 2017 $
.Dt RC.D 8
.Os
.Sh NAME
@@ -115,10 +115,7 @@ Routing table to run the daemon under, using
.Xr route 8 .
.It Ar daemon Ns _timeout
Maximum time in seconds to wait for the
-.Cm start
-(only if
-.Va rc_bg
-is set),
+.Cm start ,
.Cm stop
and
.Cm reload
diff --git a/share/man/man8/rc.subr.8 b/share/man/man8/rc.subr.8
index 5b9c0bf1741..239aadaed9c 100644
--- a/share/man/man8/rc.subr.8
+++ b/share/man/man8/rc.subr.8
@@ -1,4 +1,4 @@
-.\" $OpenBSD: rc.subr.8,v 1.32 2016/09/07 13:12:42 ajacoutot Exp $
+.\" $OpenBSD: rc.subr.8,v 1.33 2017/05/27 13:51:52 ajacoutot Exp $
.\"
.\" Copyright (c) 2011 Robert Nagy, Antoine Jacoutot, Ingo Schwarze
.\" All rights reserved.
@@ -24,7 +24,7 @@
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd $Mdocdate: September 7 2016 $
+.Dd $Mdocdate: May 27 2017 $
.Dt RC.SUBR 8
.Os
.Sh NAME
@@ -79,11 +79,7 @@ Override the
.Va pexp
variable or any of the
.Ic rc_*
-functions and set the
-.Va rc_bg
-or
-.Va rc_reload
-variables, if needed.
+functions and variables, if needed.
.It
Define an
.Ic rc_pre
@@ -252,10 +248,7 @@ Routing table to run the daemon under, using
.Xr route 8 .
.It Va daemon_timeout
Maximum time in seconds to wait for the
-.Cm start
-(only if
-.Va rc_bg
-is set),
+.Cm start ,
.Cm stop
and
.Cm reload
@@ -286,13 +279,6 @@ script has to redefine this variable
.Em after
sourcing
.Nm .
-.It Va rc_bg
-Can be set to
-.Cm YES
-in an
-.Nm rc.d
-script to force starting the daemon in background when using the default
-.Ic rc_start .
.It Va rc_reload
Can be set to
.Dq NO