zsh-workers
 help / color / mirror / code / Atom feed
* wait gets confused when second argument exits before first (i think)
@ 2010-04-10  1:37 Mikael Magnusson
  2010-04-10  3:31 ` Bart Schaefer
  0 siblings, 1 reply; 2+ messages in thread
From: Mikael Magnusson @ 2010-04-10  1:37 UTC (permalink / raw)
  To: zsh workers

zsh -f
localhost% sleep 2 & a=$\! ; sleep 1 & wait $a $\!
[1] 31989
[2] 31990
[2]  + done       sleep 1
[1]  + done       sleep 2
wait: pid 31990 is not a child of this shell
localhost% sleep 2 & a=$\! ; sleep 1 & wait $\! $a
[1] 32121
[2] 32122
[2]  + done       sleep 1
[1]  + done       sleep 2
localhost% sleep 1 & a=$\! ; sleep 2 & wait $\! $a
[1] 32125
[2] 32126
[1]  - done       sleep 1
[2]  + done       sleep 2
wait: pid 32125 is not a child of this shell

localhost% sleep 2 & sleep 1 & wait %1 %2
[1] 31993
[2] 31994
[2]  + done       sleep 1
[1]  + done       sleep 2
wait: %2: no such job
localhost% sleep 2 & sleep 1 & wait %2 %1
[1] 31997
[2] 31998
[2]  - done       sleep 1
[1]  + done       sleep 2
localhost% sleep 1 & sleep 2 & wait %2 %1
[1] 32001
[2] 32002
[1]  + done       sleep 1
[2]  + done       sleep 2
wait: %1: no such job

So it looks like it doesn't matter if %1 or %2 exits first, just which
is the first argument to wait.
Same happens both on current cvs and on 4.3.6.

-- 
Mikael Magnusson


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: wait gets confused when second argument exits before first (i think)
  2010-04-10  1:37 wait gets confused when second argument exits before first (i think) Mikael Magnusson
@ 2010-04-10  3:31 ` Bart Schaefer
  0 siblings, 0 replies; 2+ messages in thread
From: Bart Schaefer @ 2010-04-10  3:31 UTC (permalink / raw)
  To: zsh workers

On Apr 10,  3:37am, Mikael Magnusson wrote:
}
} So it looks like it doesn't matter if %1 or %2 exits first, just which
} is the first argument to wait.

The wait isn't performed in parallel for all the argument PIDs at once
(it's not like doing a select() on a list of file descriptors).  Rather
the shell waits for each PID in the order it appears on the command
line, before attempting to wait on the next one.

See zsh-workers/27442 and its thread for possibly-related discussion;
there doesn't appear to be a requirement that the shell keep track of
more than one already-exited asynchronous job.

-- 


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-04-10  3:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-04-10  1:37 wait gets confused when second argument exits before first (i think) Mikael Magnusson
2010-04-10  3:31 ` Bart Schaefer

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).