From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11965 invoked by alias); 10 Apr 2018 11:46:08 -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: List-Unsubscribe: X-Seq: 42616 Received: (qmail 5770 invoked by uid 1010); 10 Apr 2018 11:46:08 -0000 X-Qmail-Scanner-Diagnostics: from mailout2.w1.samsung.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(210.118.77.12):SA:0(-1.9/5.0):. Processed in 15.17103 secs); 10 Apr 2018 11:46:08 -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=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, SPF_PASS,T_DKIMWL_WL_HIGH,T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.1 X-Envelope-From: p.stephenson@samsung.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20180410114549euoutp0208493ea78a8791c91a7df25c8b332f38~kEIe5t0vp0069500695euoutp02F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1523360749; bh=o2Psa8aN5nk/IUsHE0PizticCx7OEykz+sbWVb8Ntv0=; h=Date:From:To:Subject:In-reply-to:References:From; b=D+WPmpRf9HKvafc5rKMv6sihqBYBqkPrATaHHfIrhxCNDs6CqYObHZDaZJ6L0yd1D 3n22jDFwVB5RZmzHXqos227ehUvwvtF2BQIeTuYvsUMwbcJU1UYqRW06TrzMgmVQut v0Uy2hLfj/j1ZJw8qVLxAKE4TVMtLu/jKmMb2Kss= X-AuditID: cbfec7f4-713ff700000043e4-9f-5acca3ecf920 Date: Tue, 10 Apr 2018 12:45:45 +0100 From: Peter Stephenson To: Zsh hackers list Subject: Re: "echo | ps -j $(:) | cat | cat | cat" runs components in different process groups Message-id: <20180410124545.13fccd5d@camnpupstephen.cam.scsc.local> In-reply-to: <180324150945.ZM32251@torch.brasslantern.com> Organization: SCSC X-Mailer: Claws Mail 3.13.2 (GTK+ 2.24.30; x86_64-pc-linux-gnu) MIME-version: 1.0 Content-type: text/plain; charset="US-ASCII" Content-transfer-encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrCIsWRmVeSWpSXmKPExsWy7djPc7pvFp+JMtg4j9PiYPNDJgdGj1UH PzAFMEZx2aSk5mSWpRbp2yVwZbS/W8VecFqk4umOM4wNjJMEuhg5OSQETCRurb/E3MXIxSEk sIJR4tmkZiYIp5dJ4uGJW2xdjBxgVZsPGkDElzFKdE7ZxA7hTGOSeLr2E5RzhlHixItGVpC5 QgIXGCUeLFIGsVkEVCXeTtsFFmcTMJSYumk2I4gtIqAlsePkSSYQW1ggQeLsnh1gNq+As8Th D//AajgFrCRen5rFDnIFv4CQxIVmW4iz7SWO7jkJVS4o8WPyPRYQm1lAR2LbtsfsELa8xOY1 b8FekxCYwiZxYt85FohmF4lz056xQ9jCEq+Ob4GyZSQ6Ow4yQTQ0M0qsvX+fDSLRwygxa3Eo hG0t0Xf7IiPEBj6JSdumM0OCiFeio00IosRD4tqlz1AzHSVW7W1jhQTQESaJWV3HmCYwys9C cvgsJIfPQnL4AkbmVYziqaXFuempxUZ5qeV6xYm5xaV56XrJ+bmbGIFxf/rf8S87GHf9STrE KMDBqMTDO+Hg6Sgh1sSy4srcQ4wSHMxKIrwHFwOFeFMSK6tSi/Lji0pzUosPMUpzsCiJ88Zp 1EUJCaQnlqRmp6YWpBbBZJk4OKUaGDvuXPz+64wTt/5z50S20lYz56I5DDuS+q78OrD2z4wv pQH7b2qunJ+ycfbOn2pdnbevX41PmTeRSbTIoHdhuZvC1x2O2n4ccmfSG9lLdZZsCKrxmP7t e0fenR4Lybc3Df+tl670Ezn04G7An18u6W2CZ3edf/51l1SkhYDmE2uu11L6n02EFJRYijMS DbWYi4oTAU+TesT3AgAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrELMWRmVeSWpSXmKPExsVy+t/xa7qvF5+JMji0VNPiYPNDJgdGj1UH PzAFMEZx2aSk5mSWpRbp2yVwZbS/W8VecFqk4umOM4wNjJMEuhg5OCQETCQ2HzToYuTiEBJY wiixe9d79i5GTiBnBpNE40NmiMQ5RonZn1+yQzgXGCVevXgGVsUioCrxdtouVhCbTcBQYuqm 2YwgtoiAlsSOkyeZQGxhgQSJRU8mgMV5BZwlDn/4B2ZzClhJvD41C2roESaJTdP3s4GcxC8g JHGh2RakRkLAXuLoHog5vAKCEj8m32MBsZmB5m/e1sQKYctLbF7zlhnianWJG3d3s09gFJqF pGUWkpZZSFoWMDKvYhRJLS3OTc8tNtQrTswtLs1L10vOz93ECAzZbcd+bt7BeGlj8CFGAQ5G JR7eCQdPRwmxJpYVV+YeYpTgYFYS4T24GCjEm5JYWZValB9fVJqTWnyIUZqDRUmc97xBZZSQ QHpiSWp2ampBahFMlomDU6qB0e/LEpuKnKww9iSLZ4FKD+PWGEcL2mW6LLy86EiY8vSzV83m ZhXmHpqhE1dzZbVdbIHo4SfbpcweCej7hzrc/WOS/ufG4xNcrcfL/tz9d+GJzTxOzT1vdKIt 3f+0XfBNjtYs75r2jbNu7gMr6RiD57HrbrodfiSikNvDfPn2/xgDnj2+wbwBSizFGYmGWsxF xYkAMl4vxVUCAAA= X-CMS-MailID: 20180410114547eucas1p1381ef2a12d9223b736166070a0702dcc X-Msg-Generator: CA CMS-TYPE: 201P X-CMS-RootMailID: 20180324221021epcas1p184507a6328dbd505b97db69c1f9d8194 X-RootMTR: 20180324221021epcas1p184507a6328dbd505b97db69c1f9d8194 References: <20180323161612.GB4857@chaz.gmail.com> <180323163614.ZM10192@torch.brasslantern.com> <180323221959.ZM27569@torch.brasslantern.com> <20180324080514.txxyrb3qiztu4pqt@gmail.com> <180324150945.ZM32251@torch.brasslantern.com> On Sat, 24 Mar 2018 15:09:44 -0700 Bart Schaefer wrote: > On Mar 23, 10:05pm, Joey Pabalinas wrote: > } > } > It could be I just haven't constructed the right test. > } > } It's kind of an *incredibly* unlikely edge-case but FWIW: > } > } > $ echo | ps -j $(: $(cat)) | cat | cat | cat > } > } The shell _seems_ to completely lock up after applying your patch; > on } my zsh 5.4.2 release version there are no problems (aside from > the } original process group leader issues). > > Hmm. The parent shell has received a SIGTTIN signal during > readoutput() even though the descriptor from which it is reading is > not a TTY. > > This is because the tty process group is still that of the deceased > job leader, and $(cat) is in the new process group owned by the > parent, so when $(cat) is stopped the process group stops as well. > > The parent needs to reattach to the terminal when reaping the group > leader, so that $(cat) doesn't get SIGTTYIN and so that the parent > begins receiving tty interrupts etc. again. The following is all a bit tentative... If we allow a simpler version of the patch I just posted --- where we always make the next process to start the new process group leader and shrug our shoulders over anything that's started so far --- then reattaching looks simple enough. The following's probably not sophisticated enough yet since we should only take back the terminal if the exited group leader was in the foreground. But looking at ps output while ^C is failing to have any effect suggests things are worse than that. I think at this point the parent shell hasn't actually reaped the echo (it's ), so hasn't executed this chunk of code. That's got something to do with the fact that it's got child reaping blocked while trying to read output from the the $(: ...) process --- it's executing the same code as the forked shell waiting for the cat. However, even simple-minded child unblocking didn't seem to cause the zombie to go away, at which point I got stuck. (The following change isn't going anyway near the main repository at the moment, obviously.) pws diff --git a/Src/signals.c b/Src/signals.c index 94f379e..f86ae54 100644 --- a/Src/signals.c +++ b/Src/signals.c @@ -537,6 +537,11 @@ wait_for_processes(void) #else update_process(pn, status); #endif + if (pn->pid == jn->gleader) { + jn->gleader = 0; + /* HERE: check this was actually in foreground... */ + attachtty(mypgrp); + } } update_job(jn); } else if (findproc(pid, &jn, &pn, 1)) {