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

Re: "echo | ps -j $(:) | cat | cat | cat" runs components in different process groups

2018-03-23 22:05:14 -1000, Joey Pabalinas:
> 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.

Yes, I should have mentioned that the initial problem was that
some of the processes in that command line are not running in
foreground, are not in the foreground process group of the

The initial problem at unix.stackexchange.com was on something

echo x | $(echo vipe) | cat


echo x | vipe $(:) | cat

And vipe (running an editor to edit the pipe) is suspended when
trying to read from the terminal while it's not in the
foreground process group of the terminal.


echo x | ps -j $(:) | cat | cat | cat

shows that all those ps/cat processes running in different
process groups instead of just one process group as one would

Bart explained that it was because zsh uses the first spawned
process (here to run a builtin) for the process group, makes
that the foreground process group, but by the time it spawns the
other processes, that first process has already returned and has
been waited for so zsh can't make the other processes join the
foreground process group.

I think here, zsh should not wait for that process until all the
processes in the jobs have been started and joined the process
group if that's what from a now-zombie process.

From stracing mksh, it looks like that's what it does. Stracing
ksh93, I can't seem to make it have the first process end before
the other ones are started, I'm not sure why that is.

That in a | b $(c) | d
c is not run in the same process group as the rest is probably a
separate though related issue I'd say.

That means, that one can't ^C

sleep 1 | cat $(sleep 10)

for instance.


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