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

Re: unable to wait on completed job [was: should $! give the pid of subshell?]



On Tue, 01 Dec 2009 09:52:54 +0000
Peter Stephenson <pws@xxxxxxx> wrote:
> Bart Schaefer wrote:
> > On Nov 30,  6:37pm, Peter Stephenson wrote:
> > }
> > } If it's only an issue for $! (lastpid internally), I think it's fairly
> > } straightforward to fix. I tried to make it work even if a new process
> > } with the same PID came along later.
> > 
> > This looks reasonable, but I wonder if we should make it conditional
> > on POSIX_JOBS ?
> 
> I'm not sure what that gains, apart from an extra error message; is
> there a case where it's important that exited background jobs can't be
> waited for?

I don't know either.  I've committed it checking for POSIXJOBS only in
wait, so you can set that just for the wait command and it will work.  We
probably need some documentation.

There's a race here if process numbers are being used up megafast, but it's
unlikely enough I haven't bothered mentioning it.

Index: Doc/Zsh/options.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/options.yo,v
retrieving revision 1.86
diff -u -r1.86 options.yo
--- Doc/Zsh/options.yo	21 Jul 2009 09:35:20 -0000	1.86
+++ Doc/Zsh/options.yo	2 Dec 2009 09:51:56 -0000
@@ -1324,6 +1324,11 @@
 shell is saved for output within a subshell (for example, within a
 pipeline).  When the option is set, the output of tt(jobs) is empty
 until a job is started within the subshell.
+
+When the option is set, it becomes possible to use the tt(wait) builtin to
+wait for the last job started in the background (as given by tt($!)) even
+if that job has already exited.  This works even if the option is turned
+on temporarily around the use of the tt(wait) builtin.
 )
 enditem()
 

-- 
Peter Stephenson <pws@xxxxxxx>            Software Engineer
Tel: +44 (0)1223 692070                   Cambridge Silicon Radio Limited
Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK


Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom



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