Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[PATCH] Do not send duplicate signals when MONITOR is set
- X-seq: zsh-workers 49029
- From: Erik Paulson <epaulson10@xxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: [PATCH] Do not send duplicate signals when MONITOR is set
- Date: Mon, 7 Jun 2021 10:27:53 -0700
- Archived-at: <https://zsh.org/workers/49029>
- List-id: <zsh-workers.zsh.org>
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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author