From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12848 invoked by alias); 23 Sep 2016 01:18:54 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 39420 Received: (qmail 26115 invoked from network); 23 Sep 2016 01:18:54 -0000 X-Qmail-Scanner-Diagnostics: from mail-pf0-f170.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(209.85.192.170):SA:0(0.0/5.0):. Processed in 0.812896 secs); 23 Sep 2016 01:18:54 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.1 X-Envelope-From: schaefer@brasslantern.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: none (ns1.primenet.com.au: domain at brasslantern.com does not designate permitted sender hosts) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=from:message-id:date:in-reply-to:comments:references:to:subject :mime-version; bh=pWtrQX7m0Akpcpjn+uAVvAf79zSVVZfZEYR8wycCw6M=; b=DZls5fNQzkXRPx04r2TghsIcILFbZU4Zxjdi2StA0X0H1BAOspiSJ2apYmkIP7Gvyf 0+nqUh8IemnWhSZ4r+Uxkb09kgquzbiiw9c6xlE6GhtAmFpnR9PyL3HxBlgMlcOfUstv jI5/FfbTDMyES7V2Vm2ZmhybGN6FeVLkBxk0oO48782gM/8Cby1WrncMPSOXKdpOHDMh 9zNy3cLsxYxC+cbaDZIajLDfJU6WF+4ysFhkJNBkZgk+t7AgfEuhLlaUB00rK4NRrWxT pXJtoiEPiROo4gMHCLEFlBMNSw2sANjc++UqU0/I4Y9Curi8EplcIprJJZsiASEY3N85 TyKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:message-id:date:in-reply-to:comments :references:to:subject:mime-version; bh=pWtrQX7m0Akpcpjn+uAVvAf79zSVVZfZEYR8wycCw6M=; b=W1bbKl3+wlxIfN9DaMXaYT0BMJd7oh+KiSRyS3cBAUHvN/RK365b9ONMv1PfXatPOv +52q4V/G1BRzOPgep9dK/Yx92xriEjxLfNe8HKWReO/y7x8v+nlapGu7pquQToOj0B79 146V1Hhjm5lM+gfBF3KwaPpcHKQ/sQW8emZEBl7WoWOS2sOVpTDENc5/7CApjcOc3Sn2 jMk3f/Tw4n6NuxBUCINgH2UOY1thCCpNLk1ghgVAVm+A4YCRmR71zS559jqMGTRA+Ht5 z6w9rXYoQgPSl0QwB5x5NK9yrkkgT0Fflb6CZYUkT3+gNqRwqZpnOxt3sRAFiw0P4IO+ 9ZlQ== X-Gm-Message-State: AE9vXwM6p7ondsZTCmEzXPIpat4vY3n3XczVsxl4N9ExAGmq3Yd0H9HB3yxGRNeLAPYlqA== X-Received: by 10.98.24.71 with SMTP id 68mr8226012pfy.65.1474593527118; Thu, 22 Sep 2016 18:18:47 -0700 (PDT) From: Bart Schaefer Message-Id: <160922181847.ZM22524@torch.brasslantern.com> Date: Thu, 22 Sep 2016 18:18:47 -0700 In-Reply-To: <160922093838.ZM7266@torch.brasslantern.com> Comments: In reply to Bart Schaefer "Re: Bug related to stdin/always/jobcontrol" (Sep 22, 9:38am) References: <87r392jgd0.fsf@juno.home.vuxu.org> <20160905164207.4630643b@pwslap01u.europe.root.pri> <20160914183105.69862fa9@pwslap01u.europe.root.pri> <20160914223553.3173c8ca@ntlworld.com> <20160922115921.GA3613@fujitsu.shahaf.local2> <160922093838.ZM7266@torch.brasslantern.com> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-workers@zsh.org Subject: Re: Bug related to stdin/always/jobcontrol MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Sep 22, 9:38am, Bart Schaefer wrote: } Subject: Re: Bug related to stdin/always/jobcontrol } } On Sep 22, 11:59am, Daniel Shahaf wrote: } } } } % f() { $EDITOR } } } % f } } } } zsh: suspended f } } % fg } } [1] + continued f } } zsh: suspended (tty output) f } } Worse that that, signals go to the parent shell: } } torch% kill -9 %1 } Vim: Caught deadly signal HUP } Vim: Finished. } zsh: killed Src/zsh -f The signal is being sent from here (signals.c): 755 if (killpg(jobtab[jn->other].gleader, sig) == -1 && errno != ESRCH) The problem is that jobtab[jn->other].gleader is 0, so killpg kills the current process. Obviously the group leader should never be zero, but I haven't figured out how to track down where it's [not] being set. Probably this is related to the shell function not properly attaching to the tty when foregrounded. However, in attempting to figure it out, I found some sixteen-year-old code that is clearly wrong: diff --git a/Src/exec.c b/Src/exec.c index d924148..bf97b5c 100644 --- a/Src/exec.c +++ b/Src/exec.c @@ -1702,7 +1702,7 @@ execpline(Estate state, wordcode slcode, int how, int last1) jobtab[list_pipe_job].other = newjob; jobtab[list_pipe_job].stat |= STAT_SUPERJOB; jn->stat |= STAT_SUBJOB | STAT_NOPRINT; - jn->other = pid; + jn->other = list_pipe_job; jn->gleader = jobtab[list_pipe_job].gleader; } if ((list_pipe || last1) && hasprocs(list_pipe_job)) jn->other is a job table index, not a process ID. However, (a) I don't know if list_pip_job is the right value (although a few lines earlier list_pipe_pid = pid is assigned, so it would seem to makes sense) and (b) that this has never caused a wild pointer dereference in all this time seems to indicate that this code is never actually reached. I don't have any more time to look at this now; hoping this information is helpful to PWS if he has a chance to look when he wakes up on Friday.