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-25 08:48:27 +0100, Stephane Chazelas:
[...]
> Note that with ksh93, like in other shells, one can't delay the
> creation of the other processes with command substitutions as
> they are not done in the main process.
[...]

Well, no that's not true. Since like in zsh, the last pipe
component is not evaluated in a child, in:

sleep 1 | { ps -j; sleep 2; ps -j; }

the second ps -j will be started while the original job process
group leader and everybody else in the group is gone, so has to
be in a different group. I find that ksh93 uses the shell's
process group in that case:

ksh93$ alias sleep=/bin/sleep # otherwise sleep is the builtin one
ksh93$ sleep 1 | { ps -j; sleep 2; ps -j; }
  PID  PGID   SID TTY          TIME CMD
 7765  7765  7765 pts/6    00:00:00 zsh
 7771  7771  7765 pts/6    00:00:00 ksh93
20782 20782  7765 pts/6    00:00:00 sleep
20783 20782  7765 pts/6    00:00:00 ps
  PID  PGID   SID TTY          TIME CMD
 7765  7765  7765 pts/6    00:00:00 zsh
 7771  7771  7765 pts/6    00:00:00 ksh93
20785  7771  7765 pts/6    00:00:00 ps


I find that a  sleep 1 | { sleep 2; echo go; sleep 10; } cannot
be suspended after "go". I've seen ksh93 also become very
confused and claiming "no job control" in one situation.

Do we agree that in:

{ a; b; c & } | d $(e) > $(f) | { g $(h); i; }

All those processes should ideally run in the same process group
as they're meant to be part of the same job? Or at least that at
any given time, all running processes in there should be in the
same process group and that process group be the foreground one?

process substitution probably have to be different. AFAICT, in
all shells, they run in background. Some even let you access
them with $! (or $apids in rc) and wait for them. There's also
the exec 3> >(cmd) where clearly cmd has to be in background.

-- 
Stephane



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