Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Bug in sh emulation



On Sun, 11 Dec 2011 15:39:18 -0800
Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> 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 <pws@xxxxxxx>            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



Messages sorted by: Reverse Date, Date, Thread, Author