On Fri, Mar 23, 2018 at 10:19:59PM -0700, Bart Schaefer wrote: > It may be this easy? > > It fixes the specific example in the subject by causing the zsh parent > shell to re-assume job leader for all subsequent processes in the pipeline > if the current leader is dead. However, I'm concerned that if the first > leader is reaped after a few processes in a long pipeline are created, > there may still be a new process group asserted for remaining processes. > > On the other hand I haven't found an example where that occurs, instead > I get jobs where the process group ID is the PID of the now-dead leader. > It could be I just haven't constructed the right test. It's kind of an *incredibly* unlikely edge-case but FWIW: > $ echo | ps -j $(: $(cat)) | cat | cat | cat The shell _seems_ to completely lock up after applying your patch; on my zsh 5.4.2 release version there are no problems (aside from the original process group leader issues). This is the shell output after I `pkill -9 cat`: > $ echo | ps -j $(: $(cat)) | cat | cat | cat > ^C^C^C^C^Z^Z^Z^Z > PID PGID SID TTY TIME CMD > 16007 16007 18994 pts/5 00:00:03 zsh > 17582 17582 18994 pts/5 00:00:01 zsh > 18994 18994 18994 pts/5 00:00:26 zsh > 20626 17582 18994 pts/5 00:00:00 ps > 20627 17582 18994 pts/5 00:00:00 cat > 20629 17582 18994 pts/5 00:00:00 cat The shell _appears_ to deadlock and accordingly ignores all user input such as ^C or ^D (but you can, however, still externally kill the parent zsh process group leader with any fatal signal or `kill -9 cat` without issue). It seems it's mostly an issue stemming from the parent zsh process still being the process group leader; this causes cat to wait indefinitely for input while being unable to actually receive any. In my zsh release version 5.4.2 ^C works as expected, and to be honest I don't actually know if this is anything worth being concerned about. Output from the release version (no need to ^C or ^D or anything): > $ echo | ps -j $(: $(cat)) | cat | cat | cat > cat: -: Input/output error > PID PGID SID TTY TIME CMD > 21366 21366 27814 pts/12 00:00:00 ps > 21367 21367 27814 pts/12 00:00:00 cat > 21368 21368 27814 pts/12 00:00:00 cat > 27814 27814 27814 pts/12 00:00:03 zsh The "cat: -: Input/output error" and differing number of entries is kind interesting, although I would be lying if I said that I understood why. -- Cheers, Joey Pabalinas
Attachment:
signature.asc
Description: PGP signature