aboutsummaryrefslogtreecommitdiff
path: root/etc
diff options
context:
space:
mode:
authorGlen Barber <gjb@FreeBSD.org>2016-02-24 03:08:58 +0000
committerGlen Barber <gjb@FreeBSD.org>2016-02-24 03:08:58 +0000
commitaef2f6ad2e64655fcc1ab4f9b26e1c7eb20bbe00 (patch)
tree49a06192925e7142aa0663349e04525093cb5671 /etc
parent3a3f435f98f5bdab7685a03370ccf22a958645e8 (diff)
parentdc2e095538de260bf8c62570423a6e144f5090c9 (diff)
downloadsrc-aef2f6ad2e64655fcc1ab4f9b26e1c7eb20bbe00.tar.gz
src-aef2f6ad2e64655fcc1ab4f9b26e1c7eb20bbe00.zip
MFH
Sponsored by: The FreeBSD Foundation
Notes
Notes: svn path=/projects/release-pkg/; revision=295957
Diffstat (limited to 'etc')
-rw-r--r--etc/defaults/rc.conf1
-rw-r--r--etc/rc.subr26
2 files changed, 26 insertions, 1 deletions
diff --git a/etc/defaults/rc.conf b/etc/defaults/rc.conf
index b9c6b5cc4d6e..12bf3f218376 100644
--- a/etc/defaults/rc.conf
+++ b/etc/defaults/rc.conf
@@ -253,6 +253,7 @@ hostapd_enable="NO" # Run hostap daemon.
syslogd_enable="YES" # Run syslog daemon (or NO).
syslogd_program="/usr/sbin/syslogd" # path to syslogd, if you want a different one.
syslogd_flags="-s" # Flags to syslogd (if enabled).
+syslogd_oomprotect="YES" # Don't kill syslogd when swap space is exhausted.
altlog_proglist="" # List of chrooted applicatioins in /var
inetd_enable="NO" # Run the network daemon dispatcher (YES/NO).
inetd_program="/usr/sbin/inetd" # path to inetd, if you want a different one.
diff --git a/etc/rc.subr b/etc/rc.subr
index a6de452ca5b0..cdec9a245481 100644
--- a/etc/rc.subr
+++ b/etc/rc.subr
@@ -45,6 +45,7 @@ _rc_subr_loaded="YES"
SYSCTL="/sbin/sysctl"
SYSCTL_N="${SYSCTL} -n"
SYSCTL_W="${SYSCTL}"
+PROTECT="/usr/bin/protect"
ID="/usr/bin/id"
IDCMD="if [ -x $ID ]; then $ID -un; fi"
PS="/bin/ps -ww"
@@ -755,6 +756,8 @@ check_startmsgs()
#
# ${name}_nice n Nice level to run ${command} at.
#
+# ${name}_oomprotect n Don't kill ${command} when swap space is exhausted.
+#
# ${name}_user n User to run ${command} as, using su(1) if not
# using ${name}_chroot.
# Requires /usr to be mounted.
@@ -944,7 +947,8 @@ run_rc_command()
_nice=\$${name}_nice _user=\$${name}_user \
_group=\$${name}_group _groups=\$${name}_groups \
_fib=\$${name}_fib _env=\$${name}_env \
- _prepend=\$${name}_prepend _login_class=\${${name}_login_class:-daemon}
+ _prepend=\$${name}_prepend _login_class=\${${name}_login_class:-daemon} \
+ _oomprotect=\$${name}_oomprotect
if [ -n "$_user" ]; then # unset $_user if running as that user
if [ "$_user" = "$(eval $IDCMD)" ]; then
@@ -1182,6 +1186,26 @@ $command $rc_flags $command_args"
;;
esac
+
+ # Apply protect(1) to the PID if ${name}_oomprotect is set.
+ case "$rc_arg" in
+ start)
+ 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
+ fi
+ ;;
+ esac
+
return $_return
done