🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.emacs.bug
Article #1240

Controlling terminal of subprocesses under Sys V

#1240
From: munnari!sibyl.eleceng.ua.oz.au!i...
Date: Sun, 11 Dec 1988 18:15
101 lines
3605 bytes
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);
-----------------------------------------------------------------------------
Technical Details
Message-ID: <8812111638.AA12873@uunet.UU.NET>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!watmath!uunet!tut.cis.ohio-state.edu!UUNET.UU.NET!munnari!sibyl.eleceng.ua.oz.au!ian

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!watmath!uunet!tut.cis.ohio-state.edu!UUNET.UU.NET!munnari!sibyl.eleceng.ua.oz.au!ian
From: munnari!sibyl.eleceng.ua.oz.au!ian@UUNET.UU.NET
Newsgroups: gnu.emacs.bug
Subject: Controlling terminal of subprocesses under Sys V
Message-ID: <8812111638.AA12873@uunet.UU.NET>
Date: 11 Dec 88 18:15:03 GMT
Sender: daemon@tut.cis.ohio-state.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 101