🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.emacs.bug
Article #98436

Problem with controlling tty for subprocesses in Emacs-18.57/SunOS 4.1

#98436
From: Anund Lie
Date: Thu, 06 Jun 1991 07:54
55 lines
2782 bytes
We are normally running emacs "detached" under X, i.e. without a
controlling tty.  With SunOS 4.1 -- and, I assume, any system with POSIX
job control -- this makes M-x shell fail ("process shell killed").  

In the code below, the main emacs process itself opens the tty side of
the pseudo-tty (to verify accessability?)  However, emacs is
normally a process group or session leader, and if it does not have a
controlling tty, this call will also erroneously establish a
controlling tty for it.

With POSIX job control, the subprocess will be in a different session.
Therefore, it will not be able to get the same pseudo-tty as a
controlling terminal.

The quick fix below (using O_NOCTTY) is by Tor Egge
<tegge@idt.unit.no>.  I made it conditional on O_NOCTTY, such that on
systems with O_NOCTTY the whole open and check is dropped.
A better fix might be to use stat() or access() for the check and
not use open() at all.


Anund Lie
Division of Computer Systems and Telematics 
Norwegian Inst. of Technology, N-7034 Trondheim, Norway
Email: anund@idt.unit.no       (Internet)


*** process.c.orig      Wed Jan 16 02:28:48 1991
--- process.c   Tue Jun  4 14:13:51 1991
***************
*** 1032,1041 ****

    if (inchannel >= 0)
      {
! #ifndef USG
        /* On USG systems it does not work to open
!        the pty's tty here and then close and reopen it in the child.  */
!       forkout = forkin = open (pty_name, O_RDWR, 0);
        if (forkin < 0)
        report_file_error ("Opening pty", Qnil);
  #else
--- 1032,1044 ----

    if (inchannel >= 0)
      {
! #if  !defined(USG) && defined(O_NOCTTY)
        /* On USG systems it does not work to open
!        the pty's tty here and then close and reopen it in the child.
!        On systems without O_NOCTTY and POSIX job control, we risk that
!        the main emacs process accidentally gets this as the controlling
!        tty, preventing the child from getting a controlling tty. */
!       forkout = forkin = open (pty_name,  O_RDWR | O_NOCTTY, 0);
        if (forkin < 0)
        report_file_error ("Opening pty", Qnil);
  #else
Technical Details
Message-ID: <9106060754.AA19889@loke.idt.unit.no>
Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!cis.ohio-state.edu!tut.cis.ohio-state.edu!unreplyable!garbage

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: fb2f1,348bec34fa2d8ab,start
X-Google-Attributes: gidfb2f1,public
X-Google-ArrivalTime: 1991-06-06 00:54:05 PST
Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!cis.ohio-state.edu!tut.cis.ohio-state.edu!unreplyable!garbage
From: anund@IDT.UNIT.NO (Anund Lie)
Newsgroups: gnu.emacs.bug
Subject: Problem with controlling tty for subprocesses in Emacs-18.57/SunOS 4.1
Message-ID: <9106060754.AA19889@loke.idt.unit.no>
Date: 6 Jun 91 07:54:05 GMT
Sender: daemon@tut.cis.ohio-state.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 55
Approved: bug-gnu-emacs@prep.ai.mit.edu