Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 29 Apr 2013 20:10:43 -0400
From:      Glen Barber <gjb@FreeBSD.org>
To:        Raphael Eiselstein <rabe@uugrn.org>
Cc:        freebsd-rc@freebsd.org
Subject:   Re: How to set resource limits (ulimit) per service with /etc/rc.subr and /etc/rc.conf
Message-ID:  <20130430001043.GB1588@glenbarber.us>
In-Reply-To: <20130429233344.GA4769@ma.sigsys.de>
References:  <20130429233344.GA4769@ma.sigsys.de>

next in thread | previous in thread | raw e-mail | index | archive | help

[-- Attachment #1 --]
On Tue, Apr 30, 2013 at 01:33:44AM +0200, Raphael Eiselstein wrote:
> 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?
> 

You might be able to do this by using the ${name}_program rc(8)
variable.  For example (untested):

    syslogd_program="/usr/bin/ulimit [ulimit_args] /usr/sbin/syslogd"
    syslogd_flags="[...]"

Glen


[-- Attachment #2 --]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.19 (FreeBSD)

iQEcBAEBCAAGBQJRfwwDAAoJEFJPDDeguUajKsEH/31TSJMwo8tXIVLc7tJyTqIP
7nu312SfwY/OHxnL+ienXFGmRcJmZjxQaFMrq+4JaJUDuHRlS3wJbENY3ivoB+YM
iLWt0ote0kN/kh0tZM0tYMoXCKwkEZjakbhwPt/46zRuvRwO0UJwbvBBprSBgXvQ
26FIUqtrMBoXg8UKRYgyah7tR8o/lICG5VF10T4s8V4gj5uacC7vAY5ewHIXlXln
9rYyFZZ6HztYBSyxrsgiXirHpvHVahijw5fj4lPWi16oysvi7n87g00eNRk3KDLn
jZkk3iriD7uqfI6+qu5oUUm7FTUfqhLcMjqot8LyRjvbLsjmjPgxgpe3mJXyTiQ=
=zd1z
-----END PGP SIGNATURE-----

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20130430001043.GB1588>