From: Erik Paulson <epaulson10@gmail.com>
To: zsh-workers@zsh.org
Subject: [PATCH] Do not send duplicate signals when MONITOR is set
Date: Mon, 7 Jun 2021 10:27:53 -0700 [thread overview]
Message-ID: <20210607172753.222432-1-epaulson10@gmail.com> (raw)
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
next reply other threads:[~2021-06-07 17:27 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-07 17:27 Erik Paulson [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210607172753.222432-1-epaulson10@gmail.com \
--to=epaulson10@gmail.com \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).