Mailing List Archive

setrlimit() before forking?
Ran into a problem on a server where it was unable to fork off a
CGI process because user "nobody" had a default low process limit. My
solution was to either do an "unlimit" from csh as root, then starting
the server, or write a csh script wrapper around httpd. What do
people think of adding a setrlimit() call in the parent process to
raise/set resource limits before firing off the children?
--
Brian ("Though this be madness, yet there is method in't") Tao
taob@gate.sinica.edu.tw <-- work ........ play --> taob@io.org
Re: setrlimit() before forking? [ In reply to ]
At 6:14 PM 8/9/95, Brian Tao wrote:
(...snip...)
>What do
>people think of adding a setrlimit() call in the parent process to
>raise/set resource limits before firing off the children?

Portability will bean issue with that call as well... if it gets put in,
#ifdef it, ("HAVE_SETRLIM" ?) and #undef it in the AUX-specific section of
conf.h...

Thanks,

-ech
Re: setrlimit() before forking? [ In reply to ]
On Wed, 9 Aug 1995, Eric Hagberg wrote:
>
> Portability will bean issue with that call as well... if it gets put in,
> #ifdef it, ("HAVE_SETRLIM" ?) and #undef it in the AUX-specific section of
> conf.h...

I envision additional httpd.conf entries that allow the server
admin to limit the amount of processes, memory, CPU time, file
creation size, etc. This would be especially nice for controlling
poorly-written or buggy CGI scripts. Set a reasonable CPU limit on
them, and the kernel zaps them before they do any real damage.

What does A/UX use for resource limits? The setrlimit() call on
the systems I have here (FreeBSD 2.0.5, SunOS 4.1.3, Solaris 2.4, IRIX
5.2/6., AIX 3.2.5) are thankfully consistent, so there shouldn't be
too much work to make it work on systems that support it.
--
Brian ("Though this be madness, yet there is method in't") Tao
taob@gate.sinica.edu.tw <-- work ........ play --> taob@io.org
Re: setrlimit() before forking? [ In reply to ]
Re: setrlimit() before forking? [ In reply to ]
Re: setrlimit() before forking? [ In reply to ]
On Wed, 9 Aug 1995, Chuck Murcko wrote:
>
> One additional nit: BSDI 2.0's [get|set]rlimit are broken. I have to use the
> old getdtablesize() to find out a valid # of descriptors.

Blah... does this affect only RLIMIT_NOFILE, or all resource types
(since you mentioned getdtablesize() to find the number of file
descriptors)?

> No word of fixes yet from BSDI; perhaps it's time to put in the FreeBSD
> versions here. 8^)

You mean some people still run their servers on BSD/OS instead of
FreeBSD? Shocking. ;-) Check out http://aries.ibms.sinica.edu.tw/
and look at the bottom of the page. :)
--
Brian ("Though this be madness, yet there is method in't") Tao
taob@gate.sinica.edu.tw <-- work ........ play --> taob@io.org
Re: setrlimit() before forking? [ In reply to ]