Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Bug in ulimit ?



On Tue, Apr 17, 2007 at 01:53:55PM +0100, Stephane Chazelas wrote:
[...]
> The limit doesn't seem to get inherited by the child process:
> 
> ~$ perl -MBSD::Resource -le 'setrlimit(RLIMIT_CPU,0,RLIM_INFINITY); print for getrlimit(RLIMIT_CPU); while (1) { ; }'
> 0
> -1
> zsh: cpu limit exceeded  perl -MBSD::Resource -le
> (152)~$ perl -MBSD::Resource -le 'setrlimit(RLIMIT_CPU,0,RLIM_INFINITY); print for getrlimit(RLIMIT_CPU); if (fork) {wait} else {while (1) { ; }}'
> 0
> -1
> <Ctrl-C>
[...]

That doesn't explain everything though.

In 

zsh -c 'ulimit -t 0; (while :; do :; done)'

we get the SIGXCPU, but that's because of zsh's optimisation not
to fork() for the () that is the last statement of the inline
script.

zsh -c 'ulimit -t 0; (while :; do :; done); :'

lasts more than 1 second.

$ sh -c 'ulimit -t 0; sh -c "ulimit -t"; :'
0

So it would seem that the limit is inherited but not applied in
the child (and I couldn't see any signal being blocked or
ignored). So that's probably not a libc issue, rather a Linux
issue.

-- 
Stéphane



Messages sorted by: Reverse Date, Date, Thread, Author