Understanding ulimit -u

Posted by tripleee on Server Fault See other posts from Server Fault or by tripleee
Published on 2012-11-16T10:52:42Z Indexed on 2012/11/16 11:03 UTC
Read the original article Hit count: 181

Filed under:
|
|

I'd like to understand what's going on here.

linvx$ ( ulimit -u 123; /bin/echo nst )
nst

linvx$ ( ulimit -u 122; /bin/echo nst )
-bash: fork: Resource temporarily unavailable
Terminated

linvx$ ( ulimit -u 123; /bin/echo one; /bin/echo two; /bin/echo three )
one
two
three

linvx$ ( ulimit -u 123; /bin/echo one & /bin/echo two & /bin/echo three )
-bash: fork: Resource temporarily unavailable
Terminated
one

I speculate that the first 122 processes are consumed by Bash itself, and that the remaining ulimit governs how many concurrent processes I am allowed to have. The documentation is not very clear on this. Am I missing something?

More importantly, for a real-world deployment, how can I know what sort of ulimit is realistic? It's a long-running daemon which spawns worker threads on demand, and reaps them when the load decreases. I've had it spin the server to its death a few times. The most important limit is probably memory, which I have now limited to 200M per process, but I'd like to figure out how I can enforce a limit on the number of children (the program does allow me to configure a maximum, but how do I know there are no bugs in that part of the code?)

© Server Fault or respective owner

Related posts about linux

Related posts about unix