rc.subr: Make sure oomprotect protects existing children

The rc(8) framework support protecting services from OOM killer.
The current implementation applies the protection after the service has
already started. This works fine if only the main process is to be
protected (*_oomprotect=yes). However, the current implementation fails
to protect existing children when children are also to be protected
(*_oomprotect=all). This patch fixes that.

Note: it is not easy to apply the protectoin earlier because we want to
support both the services which use the "command" variable and those
that use the "start_cmd" variable.

PR:		256148
Approved by:	adrian, osogbo
Tested by:	Jamie Landeg-Jones <jamie@catflap.org>
Fixes:		3bead71e95 - Add a global option where we can protect
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D35747
This commit is contained in:
Mike Walker 2022-07-07 22:28:37 +02:00 committed by Mateusz Piotrowski
parent c4995b69db
commit 68e035c017

View file

@ -1289,7 +1289,7 @@ $command $rc_flags $command_args"
[ -z "${rc_pid}" ] && eval $_pidcmd
case $_oomprotect in
[Aa][Ll][Ll])
${PROTECT} -i -p ${rc_pid}
${PROTECT} -d -i -p ${rc_pid}
;;
[Yy][Ee][Ss])
${PROTECT} -p ${rc_pid}