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.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 4828 invoked from network); 7 Jun 2021 18:45:34 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 7 Jun 2021 18:45:34 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1623091534; b=ZZpQy4VKoyLVLtAFJWaRYyQP8LEDiPZi67OMVpr5zFzjBtvkwYxdrObDXk0/E8QpbijgC4jiFO H9p6jAioOS9zwFmIuyC41DPgjlB+QJVa0nr5Kr6FS1cmrAY/xrSHpWLHRtdfFxwqGJU0SKNklt Ni0XxYWkjKn+8VL/rqhb9ftKOk8/LDIMGcghV1HIfemOOu/8caJhlzj+waenF+a+xmy3r8VvTr Rv0Ee4APzKCg2JNTgpPKvqsFgMpGm+zYvt9vK/V1Xl17Vr6kEMJo/z+EnGXzmNzwQ5X4HGTbMQ uVAQKQoJZohFsXPXOzdb0qNcE8gIjdOj5i7oJAUdHN7HOA==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-oi1-f169.google.com) smtp.remote-ip=209.85.167.169; dkim=pass header.d=brasslantern-com.20150623.gappssmtp.com header.s=20150623 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20200801; t=1623091534; bh=0g6Zb/cTyiCz0I/b8SsQSkxqFPNO8wqrwx1kgt2x+8Y=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:Cc:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:DKIM-Signature:DKIM-Signature; b=tkDA2sZYh6vjC4iVGkUhlan33hc6fN0uTqxwKWIckHkd/pjfFW7OCO2+oKNCUtdhK2Ns+g88aL dKItHNllxbsFRQ11DIfCooLYnyQo3Y8E59L7V2dFycBchn2c3EpNuwCgdrRS13pCjOImrpYIe6 T7uBRvsTZSE1Xl6/EeTS3GO6MZ2fLZ60v1IMKyWZIlceOK/FsS4InLUbhEv4V5idBKqGzh7eZc 9pQcfF/sq7NIYWZITJl+SmFi+8a7OLTmbPghXzljAqKfwB8LNlEtXAoqPuMUo7Nxn8HjIiKDfT VHRoR1QSDzwjeZmG2HXILV5bRDFFKqfNxIi2BRJ2eznwvA==; 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-Type:Cc:To:Subject:Message-ID :Date:From:In-Reply-To:References:MIME-Version:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=xINYHD/mV0ToRZFdWDJOYp2TMgDzvA5naac/81AvFZc=; b=vbfXRQdKMY2XKeuY28hGn3ckl8 X83WJPSNkD5gCJZ6SDsoVBeyoFFOMq+M/SlQ0snlH85ZJ62iWl9CdS7KYQDbDECLn2eZHfsvnIUUe lEt2f2d/y10duXfFGB/j0H/kHjXpl56Qw+c7lk4uFsjwxe81S7bbDQRzkc45ysoacAKnEVIU5QvkU aw84ukq6y2+5r1NCwXSEyfveYm6Q+awN8sUs7ylIOBYbh2L7p6xzzhcSGUtMNxyv4jPXuS1XdrmCG uliLKHvz4orYeCuBVmPT1MS+0kPG8YPd4mxVlfGm5SIkM6UK90ccn0vMCDgx+5JSx0apyYJROo4w6 hLAK8TRQ==; Received: from authenticated user by zero.zsh.org with local id 1lqKFi-000A36-Cm; Mon, 07 Jun 2021 18:45:34 +0000 Authentication-Results: zsh.org; iprev=pass (mail-oi1-f169.google.com) smtp.remote-ip=209.85.167.169; dkim=pass header.d=brasslantern-com.20150623.gappssmtp.com header.s=20150623 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none Received: from mail-oi1-f169.google.com ([209.85.167.169]:38863) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1lqKFS-0009ki-6x; Mon, 07 Jun 2021 18:45:19 +0000 Received: by mail-oi1-f169.google.com with SMTP id z3so19070852oib.5 for ; Mon, 07 Jun 2021 11:45:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=xINYHD/mV0ToRZFdWDJOYp2TMgDzvA5naac/81AvFZc=; b=P4KzTkntcPzAdyT/6iIW7/IKzA48v8eg6kVVnwCcwaOZ18NYWVwEONHdbqtnssOP53 5+tx23F4vpvzl2eRxfgoRKIbg84/KAApwZ/LhByVf1Op2dvPqSgijRMP5HJ/9XTaWaOm Qso67E/roHf3XWq2lDpXXTZS4oc08r2AxvOvf0EQrjy5OZKaija19zcm3UUc8EjyCEVN Zm8+/FIbLBqvQzUquxnH8jLXhWHp+Op0fOClYJmosb+ceEAOV/PTb260Cs9EGMrKI4Nj CnGVUm32mYj0XMTrlc0MKwP+TiVXYw/f4O3TmrjZbAqtc6CmKtmedZQqCms40dH79U6n cVgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=xINYHD/mV0ToRZFdWDJOYp2TMgDzvA5naac/81AvFZc=; b=E+BFDzotbKhCfUcFmd2CXcwXcNuDoTk7T9kftXGVv94IiF5PvsZHDgCtLbYXhC8O+K LMIYBwQLgm5qwJUp6USA4PWeGm1q6J7/fD3esME8goPUs4d7lKRSalYDZCAGp8PcNP8F FDStCaw3PjqzvwEvi2PPyHpnbUHjtMaZmK2VMJyfdjls+y5DA9gR1wVHr17M6KiivQu6 atyoov+0I6ThYUQ9/HsXPn++cdYJbagkUt4IL52qVONb/WwVPX6n0S1cCHNP+Y42Ef3M n8QWaay3MJEJPCQTMnga+Z9OLOjkG8RX6zhQiQZsNubuYQTTZaqjZRrIMQXLDVOJgdP/ j2GA== X-Gm-Message-State: AOAM533LPnfxJELCVdhJxdZiyCZC6pfzz3pTa1WDDN2fmRN3C0SBbmbo 6dqSlcs+iPKcRCE6vGTxmeETA5mP4yGrnPJrHC/iIQ== X-Google-Smtp-Source: ABdhPJyFzn2VRGYQNsfrL1pkf4KbySlC/bcT5tOIe0Df9mO5TCViFvcPyFha3WiuhCp7RFAV4yhP1ZSmSl4xaICbb2I= X-Received: by 2002:a54:4f99:: with SMTP id g25mr350891oiy.132.1623091516764; Mon, 07 Jun 2021 11:45:16 -0700 (PDT) MIME-Version: 1.0 References: <20210607172753.222432-1-epaulson10@gmail.com> In-Reply-To: <20210607172753.222432-1-epaulson10@gmail.com> From: Bart Schaefer Date: Mon, 7 Jun 2021 11:45:05 -0700 Message-ID: Subject: Re: [PATCH] Do not send duplicate signals when MONITOR is set To: Erik Paulson Cc: Zsh hackers list Content-Type: text/plain; charset="UTF-8" X-Seq: 49030 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: On Mon, Jun 7, 2021 at 10:28 AM Erik Paulson wrote: > > 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. > > 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. I don't think it was removed ... similar code was added in two separate places, but the "return" was only added in one of those. Your patch adds that return in the second case. The difference is that in the first case, the SIGCONT is received by a job that is marked STAT_SUPERJOB and in the second case it's received by a different job. I believe this means that in the former case the superjob is in the foreground and in the second case, it isn't -- rather one of its subjobs is. In the first instance zsh sends the signal to all the subjobs and then to the process group. In the second case it sends the signal to the process group first and then falls into the loop sending the signal to any subjobs that still appear to be stopped. In any case I think a potential problem with placing an unconditional "return" where your patch does, is that signals other than SIGCONT probably still need to be delivered to the subjobs. PWS, any input here? > 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. This is probably a process scheduling difference rather than a signal being suppressed, e.g., on Linux the order of events is 1) zsh sends signal to process group 2) process group copies signal to all processes 3) those processes resume 4) zsh proceeds into makerunning() and clears the STAT_STOPPED flag 5) that makes the loop a no-op Whereas on OSX, 1) zsh sends signal to process group 2) zsh proceeds into makerunning() so STAT_STOPPED is left in place 3) process group copies signal to all processes 4) the loop sends a second SIGCONT 5) those processes resume and get a double SIGCONT (2 & 3 might be simultaneous or in either order)