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
On Mon, 23 Apr 2018 14:52:38 +0100
Peter Stephenson <p.stephenson@xxxxxxxxxxx> wrote:
> > zsh% ls | less
> > zsh: done ls |
> > zsh: suspended (tty output) less
>
> Hmmm --- I wonder if less was already forked and that's the problem?
> So maybe we should check if there are other processes already forked
> and avoid resetting the pgrp leader in that case? Does anyone
> actually know?
Actually, I think this is the *other* thing I was wondering about but
didn't get around to taking account of...
See if this makes it reliable. I don't think it breaks the original
fix.
The main reason I didn't do this is the effect of killpg with signal 0
isn't actually defined in the Linu man pages or as far as I can see in
POSIX. But we do this elsewhere so presumably it's a well-known fact
this works...
pws
diff --git a/Src/signals.c b/Src/signals.c
index 6e12158..f2165c0 100644
--- a/Src/signals.c
+++ b/Src/signals.c
@@ -538,7 +538,8 @@ wait_for_processes(void)
update_process(pn, status);
#endif
if (WIFEXITED(status) &&
- pn->pid == jn->gleader) {
+ pn->pid == jn->gleader &&
+ killpg(pn->pid, 0) == -1) {
jn->gleader = 0;
if (!(jn->stat & STAT_NOSTTY)) {
/*
Messages sorted by:
Reverse Date,
Date,
Thread,
Author