daemontools and ulimit

4

1

I have a daemontools service whose /service/myservice/run contains:

#!/bin/sh
exec setuidgid someuser somecommand

Now, if I run this as a script directly from a root shell, somecommand will get a correct ulimit (unlimited).

However, when I start the service using

svc -u /service/myservice

then somecommand does get a ulimit effectively slightly above 11000.

How can I have somecommand get the correct ulimit even when started via svc (not from a shell)?

This is on FreeBSD 9 release.

oberstet

Posted 2012-06-07T16:30:53.200

Reputation: 205

Answers

1

Put the ulimit in the daemontools script, above the exec. svc does not propagate the rlimits to the scripts it runs:

#!/bin/sh
ulimit -n 102400 #Increase file descriptor limit to 102400
exec setuidgid someuser somecommand

user49740

Posted 2012-06-07T16:30:53.200

Reputation: 2 850

4

Actually, this is what softlimit is for.

You should try:

exec setuidgid someuser softlimit -o 102400 somecommand

See: http://cr.yp.to/daemontools/softlimit.html

Note that -o controls open file descriptors for softlimit, unlike -n for ulimit.

oo.

Posted 2012-06-07T16:30:53.200

Reputation: 160