today), but this requires kernel recompilation. If possible, sysctl(8)
knobs should be provided to permit to change this default value instead. If
this worked, init(8) would not need to be modified.
- I implemented a small rc.d script which might do the trick (to be tested).
- If this works, ideally /etc/defaults/rc.conf should include rlimit=YES and
+ I implemented a small rc.d script which although hackish, solves the issue.
+ Once improved, ideally /etc/defaults/rc.conf should include rlimit=YES and
new systems should come with an /etc/rlimit.conf file.
#!/bin/sh
#
-# $Id: netbsd_improvements.txt,v 1.47 2015/07/22 13:46:08 mmondor Exp $
+# $Id: netbsd_improvements.txt,v 1.48 2015/07/22 21:40:14 mmondor Exp $
#
+# If too early at boot, the sysctl commands somehow fail.
+# After sysctl, they seem to affect init(8), but even applying
+# limits to process IDs 1 and $$ are not enough for those to
+# be inherited to all future non-login daemons (i.e. started
+# later via rc.local or other rc scripts).
+# It might be slightly overkill, but to be sure that they get
+# inherited we apply the limits to all currently existing
+# processes, which works.
+
# PROVIDE: rlimit
-# BEFORE: wdogctl
+# REQUIRE: sysctl
+# BEFORE: network
$_rc_subr_loaded . /etc/rc.subr
rlimit_start()
{
- echo "Configuring init(8) rlimits."
- if [ -f "$conf" ]; then
- cat $conf | while read l; do
- /sbin/sysctl -w proc.1.rlimit.${l}
- done
- else
- echo "Warning: $rcvar enabled but $conf missing."
- fi
+ echo "Configuring default rlimits."
+ if [ -f "$conf" ]; then
+ /bin/cat "$conf" | while read l; do
+ for p in $(/bin/ps -axopid=); do
+ /sbin/sysctl 2>/dev/null -q -w \
+ proc.$p.rlimit.$l
+ done
+ done
+ else
+ echo "Warning: $rcvar enabled but $conf missing."
+ fi
+ exit 0
}
rlimit_status()
{
- /sbin/sysctl proc.1.rlimit | /usr/bin/sed 's/proc.1.rlimit.//g'
+ /sbin/sysctl proc.1.rlimit | /usr/bin/sed 's/proc.1.rlimit.//g' | \
+ /usr/bin/sed 's/\ //g'
}
load_rc_config $name