zsh-workers
 help / color / mirror / code / Atom feed
* [PATCH] Do not send duplicate signals when MONITOR is set
@ 2021-06-07 17:27 Erik Paulson
  2021-06-07 18:45 ` Bart Schaefer
  0 siblings, 1 reply; 6+ messages in thread
From: Erik Paulson @ 2021-06-07 17:27 UTC (permalink / raw)
  To: zsh-workers

When job control is enabled, killjb() is sending signals to the job's group
leader via killpg(), and then falling into a loop where the job's
process list is traversed and the signal is sent to each process. This
causes signals to always be sent twice.

This patch adds a return after the killpg() call to avoid sending the
signal again.
---

I run emacs as a daemon and use the emacsclient program to connect to
it. I noticed that when I suspended the emacsclient program and
resumed it in zsh, the program would sporadically crash. After digging
into the code, I realized that emacsclient was receiving two SIGCONTs,
which caused it to send a malformed command to the daemon. While this
is definitely a problem with emacsclient, it doesn't feel right that
Zsh is sending two SIGCONTs.

I found that this return used to be present, but was removed in
https://www.zsh.org/mla/workers/2018/msg01338.html while addressing
another emacs issue. It looks to me to be an oversight, but I cannot
tell as I am not well versed in the Zsh codebase or job control. I
know that my issue goes away with this patch, and I cannot reproduce
the original issue in the linked mail thread with it either.

Note that on testing with Linux, it seems the kernel will suppress the
second signal; in order to get a test program to detect it, I have to
step through the code with the debugger. On OSX, where I originally
detected this problem, I reliably get two signals delivered each time.

 Src/signals.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Src/signals.c b/Src/signals.c
index 2c540f38f..5c787e2a8 100644
--- a/Src/signals.c
+++ b/Src/signals.c
@@ -810,6 +810,7 @@ killjb(Job jn, int sig)
 	    err = killpg(jn->gleader, sig);
 	    if (sig == SIGCONT && err != -1)
 		makerunning(jn);
+	    return err;
 	}
     }
     for (pn = jn->procs; pn; pn = pn->next) {
-- 
2.31.1



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-07-23 20:11 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-07 17:27 [PATCH] Do not send duplicate signals when MONITOR is set Erik Paulson
2021-06-07 18:45 ` Bart Schaefer
2021-06-14 19:19   ` Peter Stephenson
2021-07-18 22:55     ` Lawrence Velázquez
2021-07-19 10:00       ` Peter Stephenson
2021-07-23 20:11         ` Peter Stephenson

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).