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 16:16:13 +0000, Stephane Chazelas:
[...]
> - the first pipeline component must be a builtin or compound command

To clarify, as explained by Bart, it doesn't have to be builtin.
It's more easily reproducible with builtins as they exit quickly
but one just needs a command that exits before the command
substitution as in:

sleep 1 | ps -j $(sleep 2) | cat|cat|cat...

Another side effect is that

echo test | tee $(uname) | sleep 10 | cat

cannot be aborted with ^C as only "cat" is in foreground (echo
gone, tee (soon gone too) and sleep on their own process group).
Also, ^Z suspends cat only causing a deadlock.

That's probably a worse problem and could explain the similar
lock ups I sometimes experience in zsh.


> - the second component must have a command substitution in the
>   arguments (OK when in targets of redirections).
[...]

Following-up on my previous email, that means:

$ n=1; echo $((++n)) | cat; echo $n
2
2
$ n=1; echo > $((++n)) | cat; echo $n
1

Which looks a bit inconsistent.

-- 
Stephane



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