From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 28318 invoked from network); 7 Jun 2021 17:27:43 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 7 Jun 2021 17:27:43 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1623086863; b=D1hZFd5HlcJPdpPYP66BtPJfK1Ui9a4Becb0E+FiY84Co1J8ZTG3uiqDZvM0GLsvQls8dnuAVr 0GSnM0a1pWrQUfXm/pYaM1c+EaoVvV7WAzYTdBiFTSDuMMsvpFtXBXmL7nYPURtRc1HV1ZLXBq jgpLpJZK8X/yquO+iBDA8vJHIpzNpLYIo7kVZN8bOt4CFjaiOq3rgP8qb0lTMoDTojLYncIuOn f7xl1TwJIU66F2Um7iBaJPtQDJwyQnO/vjYOT2foWIwhZwoMowRyd1flUOD41OV+zHWSaH9FW1 lRwxYjgsfADbdlH8WtTd/PVPa5OkxTTRPRCFt829gNlFVw==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-pf1-f175.google.com) smtp.remote-ip=209.85.210.175; dkim=pass header.d=gmail.com header.s=20161025 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20200801; t=1623086863; bh=g18dz37zYKvkWR/ttR7y/O/fMANz5hvBkQUqEf+YkOA=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:MIME-Version:Message-ID:Date: Subject:To:From:DKIM-Signature:DKIM-Signature; b=fwzox5ImLF3GcIo7v7QY5gOWQ5YU7dDTowRUwKRr6/kQ+oEkyRaGh7iotURT9HStQQMbtBTBMV 5y90eM38CJBbP24axyM4g5jhwMJsO8akmiQwnxmHxI8dTMaMRJMBrP5uOCZaMUmnHrhnSkMRAi yfKSq0qriseCno4Vq7FYozRgEtoLFDp9dDe0lMkflHUZGQu9q24k8K1BFAQAyG3TPLeZJ0JnTY G6fFx6iDhMXk2XibGnPRL+s7+KwYUAMj+GboJiKCwvNMMO0aHs3udCcq6aqo7djIBlSb+D8PqZ jTWoeCBcEDqoC2S6+xDyJdk/K1hFTkYasC5ebH8yUE2dPQ==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20200801; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Transfer-Encoding: MIME-Version:Message-Id:Date:Subject:To:From:Reply-To:Cc:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References; bh=UouQ3TWR9dogGxHYo2QwzqsWOBfYPGqgb5WsoNIDeVI=; b=kMmrvCxcAnH4x5M7Dx7ltzvMOT HKCCpGqfyz+UqGFxmL8GfbmnMKc0nLciqaKQwPk31UC4ETUGxy0y/8JowpNqFpY19LyPcqS3pDUvi HVSuYv+5mdB/EbuKEocIj5YtCpI624+H2EC3b/Y3DGq/2SF28noaVt6ExygHxIiQ2vdbei/a4kSdY 4Z9b5+mzXuK+E3QTPtBhjCMQK3ZHpIwHmv6uIXMNgwXm4z88norQnzfY05ioWxv1GxY0IkMptha12 oGI/p08uqwLyegQxEvjBLqfHzPx4DdJolcrbQnyfHPsXr735LPsQfGSo6F7fVxqglFFWmqPEjkwc3 L8bDwX4A==; Received: from authenticated user by zero.zsh.org with local id 1lqJ2L-0006TM-Cp; Mon, 07 Jun 2021 17:27:41 +0000 Authentication-Results: zsh.org; iprev=pass (mail-pf1-f175.google.com) smtp.remote-ip=209.85.210.175; dkim=pass header.d=gmail.com header.s=20161025 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-pf1-f175.google.com ([209.85.210.175]:34701) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1lqJ24-0006Ce-1E; Mon, 07 Jun 2021 17:27:24 +0000 Received: by mail-pf1-f175.google.com with SMTP id g6so13615644pfq.1 for ; Mon, 07 Jun 2021 10:27:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=UouQ3TWR9dogGxHYo2QwzqsWOBfYPGqgb5WsoNIDeVI=; b=tQPYquLDTJ1NYlCfaUTcffoE8784BdET3/+fW3itpthqtbcPow/3hpZM+3gXG3IlSV mP7jGF4thUy/X4l+pdsse1QXld6JlbSczWXGB4Pc5dd1vqrZL2j0/dniYokSNc+6TjdU 7T/PL094w/lg2ylHI9eYfqtF8Pq4krp6XehO269fT2eF1MwK2ZH2PM28dqwH0JtGDani Jbn2SJ7POdqKe/N7xBl6tHfi0lW0iO6629STm98gb429EEncpN80V8D7eiR6XIKKWAbi 7GiT/SiPfeq8Bn2gL3MNhIcGvcD+o/T1IMPquIUWd519d2BZSJAm6bSCTHGRfPVNJIwJ 33pQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=UouQ3TWR9dogGxHYo2QwzqsWOBfYPGqgb5WsoNIDeVI=; b=EzsFi2/LyNxgI94FbJnJNsLWk5EtNdCXPs5LsX5dXZITG8o4nNjrnAarmIka0XBemK ksNPSDbhE0aGTjLhN6dJzhpy4gkfmfPC1EMbUKH5ZvIS/ytJNyRSa9jw2HQCUKRCJyKv sB4YhjBOVRseMqZ7VCI+oqL7fP95em5bFwWu7Obg7vnlzk1KUT422BYcW3zJ68c6qqaP /4kOTniQcJ/aY8j3tmrJGt0skr97UhF1QZgxRiRVLW8uqEDy06TxaFdFJ/uuJ+GTj//T XqdAUfWrsrT2+qvRDlJahAgpycK+/rTk93Sj5kECjlyJkKARI/n/lgjIFo5HrHDpZ9Bw 6SNw== X-Gm-Message-State: AOAM5316Gi+4Ku++94ypbA805i4soBNHL1ITM58DM15G8i3TdSUh3gxN 2ezmocLojtzDnIJhGrEdPdLMlLtaXLA= X-Google-Smtp-Source: ABdhPJykmqL3gJxYUEftQv98T5RSA24z7FHvFN2Yqvpy0chLtcc9HGgPRIBRMdxKZijlpoudx59G2g== X-Received: by 2002:a63:1d42:: with SMTP id d2mr18559452pgm.21.1623086842277; Mon, 07 Jun 2021 10:27:22 -0700 (PDT) Received: from erik-arch.localdomain (97-120-29-240.ptld.qwest.net. [97.120.29.240]) by smtp.googlemail.com with ESMTPSA id n17sm8580226pfv.125.2021.06.07.10.27.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Jun 2021 10:27:21 -0700 (PDT) From: Erik Paulson 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 Message-Id: <20210607172753.222432-1-epaulson10@gmail.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Seq: 49029 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: 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