How to set resource limits (ulimit) per service with /etc/rc.subr and /etc/rc.conf

Raphael Eiselstein rabe at uugrn.org
Mon Apr 29 23:33:52 UTC 2013


Hi everyone,

we have some generic parameters for rc-scripts like 
${name}_program  ${name}_chroot ${name}_flags ${name}_nice ${name}_user
any many more.

I'm looking for a way to configure different ulimits per service. It
seems we have nothing about "ulimit" somewhere in /etc.

I'd like to have a unique way to configure resource limits, hard and
soft limits.

Resource limits can be set within a script for the current process by 
"ulimit [-HSabcdflmnpstuvw] [limit]" but not as a parameterised wrapper
like "nice" or "chroot" or "su", so prepeding just another "ulimit"
wrapper seems not to be an option.

Is there a unique way to have resource limits per service? I didn't find
any. AFAICS we have two options handling this:

#1 writing a /bin/sh wrapper prepeding ${_doit} containing ulimit
commands

#2 having (someone) to build up a generic binary like nice(1) getting
limit-parameters by commandline before execve'ing the final command, e.g. 

limitsh -Hv 20480 -Sv 10240 -n 300 -c command args

Problem: shells shoud implement "-c command args" and ulimit uses -c for
coredumpsize in 512byte blocks. To get around this: -Hc and -Sc are 
hard/soft limits to corefilesize, a single "-c" is always the
command-string like in sh(1) 

Any ideas? Did I miss something?

Regards
Raphael

-- 
Raphael Eiselstein <rabe at uugrn.org>               http://rabe.uugrn.org/
xmpp:freibyter at gmx.de  | https://www.xing.com/profile/Raphael_Eiselstein   
GnuPG:                E7B2 1D66 3AF2 EDC7 9828  6D7A 9CDA 3E7B 10CA 9F2D
.........|.........|.........|.........|.........|.........|.........|..
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.freebsd.org/pipermail/freebsd-rc/attachments/20130430/735875fd/attachment.sig>


More information about the freebsd-rc mailing list