ian@UUNET.UU.NET (12/12/88)
In GNU Emacs 18.52.16 of Sun Dec 11 1988 on sibyl (usg-unix-v) The controlling terminal of an emacs subprocess is not set properly when running under Sys V with pseudo-terminal drivers. To do this correctly the child must call setpgrp and then open the pseudo tty in that order. I have made the following changes which seem to work. It doesn't seem possible to confine the system dependancy to setpgrp_of_tty. In process.c: Was -------------------------------------------------------------------------- #ifdef TIOCNOTTY /* In 4.3BSD, the TIOCSPGRP bug has been fixed, and now you can do TIOCSPGRP only to the process's controlling tty. We must make the pty terminal the controlling tty of the child. */ if (ptyname) { /* I wonder: would just ioctl (0, TIOCNOTTY, 0) work here? I can't test it since I don't have 4.3. */ int j = open ("/dev/tty", O_RDWR, 0); ioctl (j, TIOCNOTTY, 0); close (j); #if !defined (RTU) && !defined(UNIPLUS) #ifdef USG setpgrp (); #endif /* I wonder if close (open (ptyname, ...)) would work? */ if (xforkin >= 0) close (xforkin); xforkout = xforkin = open (ptyname, O_RDWR, 0); if (xforkin < 0) abort (); #endif /* not UNIPLUS and not RTU */ } #endif /* TIOCNOTTY */ ---------------------------------------------------------------------------- Change to: ---------------------------------------------------------------------------- /* In 4.3BSD, the TIOCSPGRP bug has been fixed, and now you can do TIOCSPGRP only to the process's controlling tty. We must make the pty terminal the controlling tty of the child. */ if (ptyname) { #ifdef TIOCNOTTY /* I wonder: would just ioctl (0, TIOCNOTTY, 0) work here? I can't test it since I don't have 4.3. */ int j = open ("/dev/tty", O_RDWR, 0); ioctl (j, TIOCNOTTY, 0); close (j); #endif /* TIOCNOTTY */ #if !defined (RTU) && !defined(UNIPLUS) #ifdef USG setpgrp (); #endif /* I wonder if close (open (ptyname, ...)) would work? */ if (xforkin >= 0) close (xforkin); xforkout = xforkin = open (ptyname, O_RDWR, 0); if (xforkin < 0) abort (); #endif /* not UNIPLUS and not RTU */ } ---------------------------------------------------------------------------- And in callproc.c Was: -------------------------------------------------------------------------- #ifdef USG setpgrp (); /* No arguments but equivalent in this case */ #else setpgrp (pid, pid); #endif /* USG */ setpgrp_of_tty (pid); ---------------------------------------------------------------------------- Change to: ---------------------------------------------------------------------------- #ifdef USG #if defined(HAVE_PTYS) && !defined(RTU) && !defined(UNIPLUS) { extern char *ptyname; if (!ptyname) setpgrp (); } #else setpgrp (); /* No arguments but equivalent in this case */ #endif #else setpgrp (pid, pid); #endif /* USG */ setpgrp_of_tty (pid); -----------------------------------------------------------------------------
mb@ttidca.TTI.COM (Michael Bloom) (12/12/88)
I hope emacs is not changed to include that code. The conditionalizations are too dependant upon specific systems! For example, I have a system V which is neither of the two exceptions given (RTU and UNIPLUS) but does support bsd style setpgrp(x,y) and TIOC[SP]GRP (but unfortunately not yet SIGSTOP, SIGCONT and friends). Chances are, if a Sys5 lacks TIOCSPGRP, it also lacks a bad-style setpgrp() and vice versa. Thus TIOCSPGRP would be a good candidate for the conditionalization. Btw, on a separate but related topic, the code for flushing input under SYS5 should really (!!!) use TCFLSH and not TCSETAW, which results in erroneous display behavior on pty's used by a full rlogin protocol. (I sent rms mail on this a while back, so hopefully a fix will appear in v19).