🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.emacs.bug
Article #99350

bug in sig_process() on HPUX 7.0

#99350
From: dutentb!stravers
Date: Mon, 01 Oct 1990 10:30
84 lines
3962 bytes
Following reports a bug in GNUemacs 18.55 for HPUX. A patch is included.

Program:            GNU emacs 18.55

Operating system:   HPUX 6.5 and HPUX 7.0

Hardware:           hp9k800, hp9k300

Problem:
Emacs is unable to send signals to inferior processes, as required for the
elisp functions interrupt-process, kill-process, etc. Consequently, \C-c\C-c in
shell-mode does not send signal 2 to the shell's subjob, in latex-mode \C-c\C-k
does not kill the running latex process, etc.

Cause  -- where it fails:
The following system call in the file src/process.c, function sig_process()
fails:

      if (!NULL (current_group))
        {
>>>       ioctl (XFASTINT (p->infd), TIOCGPGRP, &gid);   <<<<<<<< FAIL *****
          gid = - gid;
        }

The call is supposed to set gid to the process group id of the process that is
currently in the foreground of the controlling terminal whos fildes is p->infd.
In stead, ioctl returns -1 and sets errno to ENOTTY. According to the manual
page termio(7) this means that "the file associated with XFASTINT(p->infd) is
not the controlling terminal, or the calling process does not have a
controlling terminal". Here the "calling process" is emacs and the file
descriptor XFASTINT(p->infd) refers to the master side of the pty that emacs
uses to communicate with the inferior process.

Cause -- why it fails:
It seems that hpux only allows background processes WITHIN a terminal session
to obtain the gid of that sessions current foreground process.  Since the
inferior process creates its own session just after emacs forks [with the call
setpgrp()], emacs is OUTSIDE the inferior process session, hence the above
mentioned ioctl fails.

Suggested solution:
In hpux we can (must) combine the two distinct calls
          1.    ioctl ( fildes, TIOCGPGRP, &gid);
          2.    kill (-gid, signo);
into the single call
          1+2.  ioctl( fildes, TIOCSIGSEND, signo);
According to the man page pty(7) this sends the signal signo to the current tty
process group of the pty slave side.  Here are the cdiffs: 

*** process_old.c
--- process.c
**************
*** 1819,1824
       Must do that differently.  */
    killpg (-gid, signo);
  #else /* Not BSD.  */
    kill (gid, signo);
  #endif /* HPUX */
  #endif /* Not BSD.  */
--- 1819,1827 -----
       Must do that differently.  */
    killpg (-gid, signo);
  #else /* Not BSD.  */
+ #ifdef HPUX /* previous ioctl failed, gid is not valid */
+   ioctl( XFASTINT (p->infd), TIOCSIGSEND, signo);
+ #else
    kill (gid, signo);
+ #endif /* HPUX */
  #endif /* Not BSD.  */

Two notes on the patch:
  1. After this patch sig_process() still executes the failing ioctl, but since
     we discard the resulting gid anyway this does no harm.
  2. These diffs apply to the file src/process.c AFTER I patched it with Piet
     van Oostrum's (piet@cs.ruu.nl) patches to make ^G work for HPUX/X-windows.
     If you cannot get them, mail me and I'll send 'm to you.

Paul Stravers
Delft University of Technology (faculty of EE)
The Netherlands

     __           __                                                  __
____/  |____     |  \_paul__     _                                 __/  \_____
            |____|          |___/ \__stravers@dutentb.tudelft.nl__/
Technical Details
Message-ID: <9010010837.AA15646@hp4nl.nluug.nl>
Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!snorkelwacker!tut.cis.ohio-state.edu!relay.eu.net!dutentb!stravers

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: fb2f1,b8ecb8aaa43a781b,start
X-Google-Attributes: gidfb2f1,public
X-Google-ArrivalTime: 1990-10-01 06:51:25 PST
Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!snorkelwacker!tut.cis.ohio-state.edu!relay.eu.net!dutentb!stravers
From: dutentb!stravers@relay.eu.net
Newsgroups: gnu.emacs.bug
Subject: bug in sig_process() on HPUX 7.0
Message-ID: <9010010837.AA15646@hp4nl.nluug.nl>
Date: 1 Oct 90 10:30:27 GMT
Sender: daemon@tut.cis.ohio-state.edu
Reply-To: stravers@dutentb.tudelft.nl
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 84
Posted: Mon Oct  1 11:30:27 1990