rc.subr: Swap checks so we only fork sysctl if *_oomprotect is set.

This commit is contained in:
Jilles Tjoelker 2016-11-17 22:49:51 +00:00
parent 260b8f08e6
commit bddbe3b2b1
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=308786

View File

@ -1206,22 +1206,17 @@ $command $rc_flags $command_args"
case "$rc_arg" in
start)
# We cannot use protect(1) inside jails.
jailed="$(sysctl -n security.jail.jailed)"
if [ ${jailed} -eq 1 ]; then
return $_return
fi
if [ -n "$_oomprotect" ]; then
if [ -f "${PROTECT}" ]; then
pid=$(check_process $command)
case $_oomprotect in
[Aa][Ll][Ll])
${PROTECT} -i -p ${pid}
;;
[Yy][Ee][Ss])
${PROTECT} -p ${pid}
;;
esac
fi
if [ -n "$_oomprotect" ] && [ -f "${PROTECT}" ] &&
[ "$(sysctl -n security.jail.jailed)" -eq 0 ]; then
pid=$(check_process $command)
case $_oomprotect in
[Aa][Ll][Ll])
${PROTECT} -i -p ${pid}
;;
[Yy][Ee][Ss])
${PROTECT} -p ${pid}
;;
esac
fi
;;
esac