From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9128 invoked by alias); 12 Dec 2011 10:01:15 -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: 30005 Received: (qmail 26373 invoked from network); 12 Dec 2011 10:01:12 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_HELO_PASS autolearn=ham version=3.3.2 Received-SPF: none (ns1.primenet.com.au: domain at csr.com does not designate permitted sender hosts) Date: Mon, 12 Dec 2011 10:01:00 +0000 From: Peter Stephenson To: Subject: Re: Bug in sh emulation Message-ID: <20111212100100.0696825b@pwslap01u.europe.root.pri> In-Reply-To: <111211153918.ZM32739@torch.brasslantern.com> References: <111209184747.ZM5000@torch.brasslantern.com> <20111210194022.5051f91c@pws-pc.ntlworld.com> <20111210232801.7dc8fef2@pws-pc.ntlworld.com> <20111211193949.2d58062b@pws-pc.ntlworld.com> <20111211202024.07c046df@pws-pc.ntlworld.com> <20111211205658.365243c7@pws-pc.ntlworld.com> <111211153918.ZM32739@torch.brasslantern.com> Organization: Cambridge Silicon Radio X-Mailer: Claws Mail 3.7.9 (GTK+ 2.22.0; i386-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.101.11.233] X-Scanned-By: MailControl 7.6.5 (www.mailcontrol.com) on 10.68.0.136 On Sun, 11 Dec 2011 15:39:18 -0800 Bart Schaefer wrote: > } - attachtty() works because SIGTTOU is still ignored > > I think there's a flaw here: attachtty() doesn't *work*, in that it > won't actually associate the new process group with the TTY. Instead > it just won't result in an infinite loop. I'll check in more detail later, but I'm pretty sure this is how it *always* works, not just in the case we're looking at. In most cases the parent shell just lets the new process (whatever it's doing, just as long as it's in the foreground) grab the terminal --- if you search the code for attachtty(), and ignore the cases where we attaching to mypgrp, the shell's own process group, the only other ones in the parent shell are special cases. Instrumenting attachtty() didn't show any point where the parent shell handed the tty over, and if you look at the GNU documentation I pointed to, although it says both the parent shell and the new process should perform the handover to minimise races, the example code just does it from within the new process. So I think (i) the attachtty() works in the subprocess so long as SIGTTOU is blocked (ii) if that's not the case, we've got a far worse problem than just shell compatibility (and I have no direct evidence we have such a problem). -- Peter Stephenson Software Engineer Tel: +44 (0)1223 692070 Cambridge Silicon Radio Limited Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom More information can be found at www.csr.com. Follow CSR on Twitter at http://twitter.com/CSR_PLC and read our blog at www.csr.com/blog