Index: etc/defaults/rc.conf =================================================================== --- etc/defaults/rc.conf +++ etc/defaults/rc.conf @@ -253,6 +253,10 @@ 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" # Use protect(1) to avoid syslogd being killed when + # swap space is exhausted. No children processes + # are protected. To protect all children processes + # use ALL instead of YES. 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. Index: etc/rc.subr =================================================================== --- etc/rc.subr +++ etc/rc.subr @@ -755,6 +755,8 @@ # # ${name}_nice n Nice level to run ${command} at. # +# ${name}_oomprotect n Protect against OOM Killer. +# # ${name}_user n User to run ${command} as, using su(1) if not # using ${name}_chroot. # Requires /usr to be mounted. @@ -944,7 +946,8 @@ _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 @@ -1050,6 +1053,18 @@ if [ -n "$_prepend" ]; then _doit="$_prepend $_doit" fi + if [ -n "$_oomprotect" ]; then + if [ -r /usr/bin/protect ]; then + case $_oomprotect in + [Aa][Ll][Ll]) + _doit="protect -i ${command} ${rc_flags}" + ;; + [Yy][Ee][Ss]) + _doit="protect ${command} ${rc_flags}" + ;; + esac + fi + fi fi # Prepend default limits Index: share/man/man8/rc.subr.8 =================================================================== --- share/man/man8/rc.subr.8 +++ share/man/man8/rc.subr.8 @@ -29,7 +29,7 @@ .\" .\" $FreeBSD$ .\" -.Dd October 12, 2014 +.Dd February 3, 2016 .Dt RC.SUBR 8 .Os .Sh NAME @@ -604,6 +604,12 @@ Only supported after .Pa /usr is mounted. +.It Va ${name}_oomprotect +.Xr protect 1 +.Va command +from being killed when swap space is exhausted. +This is usually set in +.Xr rc.conf 5 .It Va ${name}_program Full path to the command. Overrides