[gnu.emacs.bug] PTYs

liberte@M.CS.UIUC.EDU (Daniel LaLiberte) (02/28/89)

(Posted for someone with questionable mail connection.)
(Respond to me or try ccvaxa!marick@cs.uiuc.edu)

Date: Tue, 24 Jan 89 14:33:41 CST
From: marick (Brian Marick)

Version 18.52 (with no local changes)
System: Motorola V/68 (s-usg5-3.h, HAVE_PTYS, SYSV_PTYS)
Symptom:  When configured with PTYs, programs running under a subshell
	can't open /dev/tty.  Hence, ftp (for example) doesn't work in
	a subshell, nor does rm -i, nor does "echo foo > /dev/tty".
Problem:  An ifdef seems to be misplaced.  See more comments in the
	diff -c listing below.

*** /tmp/ORIG.process.c	Tue Jan 24 14:18:52 1989
--- /tmp/process.c	Tue Jan 24 14:19:01 1989
***************
*** 1,3 ****
--- 1,11 ----
+ /* Motorola changes to the standard distribution are marked with the CHANGES 
+    comment.  
+ 
+    Jan-12-89:  Fix to make /dev/tty work on subprocesses.  -- Marick
+ 
+ */
+ 
+ 
  /* Asynchronous subprocess control for GNU Emacs.
     Copyright (C) 1985, 1986, 1987, 1988 Free Software Foundation, Inc.
  
***************
*** 987,1004 ****
  	int xforkin = forkin;
  	int xforkout = forkout;
  #ifdef HAVE_PTYS
- #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 ();
--- 995,1017 ----
  	int xforkin = forkin;
  	int xforkout = forkout;
  #ifdef HAVE_PTYS
  	/* 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)
  	  {
+ 	      /* CHANGES:  In stock 18.52, this TIOCNOTTY wrapped the same 
+ 		 code as the HAVE_PTYS.  That broke (at least) Motorola
+ 		 System V machines.  Putting it here works for both Motorola
+ 		 and Gould (BSD-4.3-derived) machines.  Don't know about RTU
+ 		 or UNIPLUS. */
+ #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 ();
***************
*** 1012,1018 ****
  	      abort ();
  #endif /* not UNIPLUS and not RTU */
  	  }
- #endif /* TIOCNOTTY */
  #endif /* HAVE_PTYS */
  	child_setup_tty (xforkout);
  	child_setup (xforkin, xforkout, xforkout, new_argv, env);
--- 1025,1030 ----