From: jca Date: Fri, 15 Dec 2023 16:59:48 +0000 (+0000) Subject: Run non-daemons services in a different process group to avoid SIGHUP at boot X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=654e8744d62bbb999d3beaa8cc20dbc25862d98a;p=openbsd Run non-daemons services in a different process group to avoid SIGHUP at boot 12 factors apps and similar don't daemonize and are thus vulnerable to receiving a SIGHUP signal at the end of /etc/rc. Shield them by running them in a different process group. Do this only for services that need rc_bg=Yes, as suggested by ajacoutot@ There have been several reports about this issue in the past years, the last one being from edd@ who successfully tested this fix. Input from several folks, ok sthen@ ajacoutot@ --- diff --git a/etc/rc.d/rc.subr b/etc/rc.d/rc.subr index 502a469af70..47b9acb41c1 100644 --- a/etc/rc.d/rc.subr +++ b/etc/rc.d/rc.subr @@ -1,4 +1,4 @@ -# $OpenBSD: rc.subr,v 1.160 2022/10/19 21:04:45 ajacoutot Exp $ +# $OpenBSD: rc.subr,v 1.161 2023/12/15 16:59:48 jca Exp $ # # Copyright (c) 2010, 2011, 2014-2022 Antoine Jacoutot # Copyright (c) 2010, 2011 Ingo Schwarze @@ -166,7 +166,15 @@ rc_exec() { [ "${daemon_rtable}" -eq "$(id -R)" ] || _rcexec="route -T ${daemon_rtable} exec ${_rcexec}" - ${_rcexec} "${daemon_logger:+set -o pipefail; } \ + local _set_monitor=":" + # Run non-daemons services in a different process group to avoid SIGHUP + # at boot. + if [ X"${rc_bg}" = X"YES" ]; then + _set_monitor="set -o monitor" + fi + + ${_rcexec} "${_set_monitor}; \ + ${daemon_logger:+set -o pipefail; } \ ${daemon_execdir:+cd ${daemon_execdir} && } \ $@ \ ${daemon_logger:+ 2>&1 |