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

Re:Re: job control problem



On Tue, Mar 06, 2012 at 09:46:08PM -0800, Bart Schaefer wrote:
> On Mar 6,  6:01pm, hanpingtian wrote:
> }
> } And I noticed that when trying to run a lot of jobs in background can
> } cause zsh quit or frozen.
> 
> Hmm.
> 
> Zsh is attempting to reclaim job table space during the SIGCLD handler.
> I did a quick test and somewhere after a few hundred jobs the child
> handler gets called during a free(), and the handler then calls free()
> again and ends up deadlocked on a system mutex in the guts of glibc.

I noticed that sometimes zsh scripts hangs up at futex(), after run some
background jobs.

> 
> This is especially likely with "zsh -x" because the PS4 prompt is
> allocated and freed each time it's printed.  If I leave off the -x,
> the whole loop to 10000 runs to completion.
> 
> However, if I try to reproduce this with bash by frobbing "ulimit -u",
> bash exits for me at exactly the same point as zsh.  In fact we just
> had a whole discussion on zsh-workers [*] about bash exiting on fork
> failure, and how zsh either did not but ought to, or exited success
> when it should probably exit with failure.
> 
> I modified t.sh to echo the loop counter so I cound run it without -x
> and still see how many iterations it made.
> 
> schaefer[501] bash --version
> GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin11)
> Copyright (C) 2007 Free Software Foundation, Inc.
> schaefer[502] bash /tmp/t.sh
> 1
> ...
> 67
> /tmp/t.sh: fork: Resource temporarily unavailable
> schaefer[503] echo $?
> 128
> 
> No "retry" mentioned.  What am I missing?
I was using bash 4.2.10 to do this testing:
% bash --version
GNU bash, version 4.2.10(1)-release (x86_64-redhat-linux-gnu)
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
<http://gnu.org/licenses/gpl.html>

Looks like the bash will retry again and again.

> 
> 
> [*] http://www.zsh.org/mla/workers/2012/msg00187.html thread up to
>     http://www.zsh.org/mla/workers/2012/msg00201.html or so




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