]> code.delx.au - gnu-emacs/blobdiff - src/process.c
* Makefile.in (doxemacs, dotemacs): Explicitly pass along the CC
[gnu-emacs] / src / process.c
index 0d187bd59fe653c91d3c4e559081033465a74e64..35a30540c02f36dc2faddf8442b4c35c5968534a 100644 (file)
@@ -48,18 +48,10 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
 
 #if defined(BSD) || defined(STRIDE)
 #include <sys/ioctl.h>
-#if !defined (O_NDELAY) && defined (HAVE_PTYS)
+#if !defined (O_NDELAY) && defined (HAVE_PTYS) && !defined(USG5)
 #include <fcntl.h>
 #endif /* HAVE_PTYS and no O_NDELAY */
 #endif /* BSD or STRIDE */
-#ifdef USG
-#ifdef HAVE_TERMIOS
-#include <termios.h>
-#else
-#include <termio.h>
-#endif
-#include <fcntl.h>
-#endif /* USG */
 
 #ifdef NEED_BSDTTY
 #include <bsdtty.h>
@@ -70,7 +62,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #endif /* not IRIS */
 
 #include "systime.h"
-#include "systerm.h"
+#include "systty.h"
 
 #include "lisp.h"
 #include "window.h"
@@ -119,15 +111,16 @@ static Lisp_Object stream_process;
 #ifndef VMS
 #ifndef WAITTYPE
 #if !defined (BSD) && !defined (UNIPLUS) && !defined (STRIDE) && !(defined (HPUX) && !defined (NOMULTIPLEJOBS)) && !defined (HAVE_WAIT_HEADER)
-mis;tak-+;;:
 #define WAITTYPE int
 #define WIFSTOPPED(w) ((w&0377) == 0177)
 #define WIFSIGNALED(w) ((w&0377) != 0177 && (w&~0377) == 0)
 #define WIFEXITED(w) ((w&0377) == 0)
 #define WRETCODE(w) (w >> 8)
 #define WSTOPSIG(w) (w >> 8)
-#define WCOREDUMP(w) ((w&0200) != 0)
 #define WTERMSIG(w) (w & 0377)
+#ifndef WCOREDUMP
+#define WCOREDUMP(w) ((w&0200) != 0)
+#endif
 #else 
 #ifdef BSD4_1
 #include <wait.h>
@@ -283,6 +276,8 @@ int proc_buffered_char[MAXDESC];
 /* Compute the Lisp form of the process status, p->status, from
    the numeric status that was returned by `wait'.  */
 
+Lisp_Object status_convert ();
+
 update_status (p)
      struct Lisp_Process *p;
 {
@@ -335,7 +330,7 @@ decode_status (l, symbol, code, coredump)
       *symbol = XCONS (l)->car;
       tem = XCONS (l)->cdr;
       *code = XFASTINT (XCONS (tem)->car);
-      tem = XFASTINT (XCONS (tem)->cdr);
+      tem = XCONS (tem)->cdr;
       *coredump = !NILP (tem);
     }
 }
@@ -373,7 +368,6 @@ status_message (status)
 }
 \f
 #ifdef HAVE_PTYS
-static int pty_process;
 
 /* Open an available pty, returning a file descriptor.
    Return -1 on failure.
@@ -1207,6 +1201,11 @@ create_process (process, new_argv)
        /* First, disconnect its current controlling terminal.  */
 #ifdef HAVE_SETSID
        setsid ();
+#ifdef TIOCSCTTY
+       /* Make the pty's terminal the controlling terminal.  */
+       if (pty_flag && (ioctl (xforkin, TIOCSCTTY, 0) < 0))
+         abort ();
+#endif
 #else /* not HAVE_SETSID */
 #ifdef USG
        /* It's very important to call setpgrp() here and no time
@@ -1268,7 +1267,9 @@ create_process (process, new_argv)
 #if defined (BSD) || defined (UNIPLUS) || defined (HPUX)
        sigsetmask (SIGEMPTYMASK);
 #else /* ordinary USG */
+#if 0
        signal (SIGCHLD, sigchld);
+#endif
 #endif /* ordinary USG */
 #endif /* not BSD4_1 */
 #endif /* SIGCHLD */
@@ -1560,6 +1561,8 @@ Return non-nil iff we received any output before the timeout expired.")
          }
       }
     }
+  else
+    useconds = 0;
 
   if (! NILP (timeout))
     {
@@ -1738,6 +1741,12 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
        {
          if (xerrno == EINTR)
            FD_ZERO (&Available);
+#ifdef __ultrix__
+         /* Ultrix select seems to return ENOMEM when it is interrupted.
+            Treat it just like EINTR.  Bleah.  -JimB  */
+         else if (xerrno == ENOMEM)
+           FD_ZERO (&Available);
+#endif
 #ifdef ALLIANT
          /* This happens for no known reason on ALLIANT.
             I am guessing that this is the right response. -- RMS.  */
@@ -1796,7 +1805,7 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
          Available &= ~(ChannelMask (comm_server));
          create_commchan ();
        }
-#endif vipc
+#endif /* vipc */
 
       if (! wait_proc)
        got_some_input |= nfds > 0;
@@ -2202,6 +2211,7 @@ Output from processes can arrive in between bunches.")
    If NOMSG is zero, insert signal-announcements into process's buffers
    right away.  */
 
+static void
 process_send_signal (process, signo, current_group, nomsg)
      Lisp_Object process;
      int signo;
@@ -2226,7 +2236,6 @@ process_send_signal (process, signo, current_group, nomsg)
   if (NILP (p->pty_flag))
     current_group = Qnil;
 
-#ifdef TIOCGPGRP               /* Not sure about this! (fnf) */
   /* If we are using pgrps, get a pgrp number and make it negative.  */
   if (!NILP (current_group))
     {
@@ -2241,45 +2250,49 @@ process_send_signal (process, signo, current_group, nomsg)
        case SIGINT:
          ioctl (XFASTINT (p->infd), TIOCGETC, &c);
          send_process (proc, &c.t_intrc, 1);
-         return Qnil;
+         return;
        case SIGQUIT:
          ioctl (XFASTINT (p->infd), TIOCGETC, &c);
          send_process (proc, &c.t_quitc, 1);
-         return Qnil;
+         return;
+#ifdef SIGTSTP
        case SIGTSTP:
          ioctl (XFASTINT (p->infd), TIOCGLTC, &lc);
          send_process (proc, &lc.t_suspc, 1);
-         return Qnil;
+         return;
+#endif /* SIGTSTP */
        }
-#endif /* have TIOCGLTC and have TIOCGETC */
+#endif /* ! defined (TIOCGLTC) && defined (TIOCGETC) */
       /* It is possible that the following code would work
         on other kinds of USG systems, not just on the IRIS.
         This should be tried in Emacs 19.  */
-#if defined (IRIS) && defined (HAVE_SETSID) /* Check for Irix, not older
-                                              systems.  */
+#if defined (USG)
       struct termio t;
       switch (signo)
        {
        case SIGINT:
          ioctl (XFASTINT (p->infd), TCGETA, &t);
          send_process (proc, &t.c_cc[VINTR], 1);
-         return Qnil;
+         return;
        case SIGQUIT:
          ioctl (XFASTINT (p->infd), TCGETA, &t);
          send_process (proc, &t.c_cc[VQUIT], 1);
-         return Qnil;
+         return;
+#ifdef SIGTSTP
        case SIGTSTP:
          ioctl (XFASTINT (p->infd), TCGETA, &t);
          send_process (proc, &t.c_cc[VSWTCH], 1);
-         return Qnil;
+         return;
+#endif
        }
-#endif /* IRIS and HAVE_SETSID */
+#endif /* ! defined (USG) */
 
+#ifdef TIOCGPGRP 
       /* Get the pgrp using the tty itself, if we have that.
         Otherwise, use the pty to get the pgrp.
         On pfa systems, saka@pfu.fujitsu.co.JP writes:
         "TICGPGRP symbol defined in sys/ioctl.h at E50.
-         But, TIOCGPGRP donot work on E50 ;-P work fine on E60"
+         But, TIOCGPGRP does not work on E50 ;-P works fine on E60"
         His patch indicates that if TIOCGPGRP returns an error, then
         we should just assume that p->pid is also the process group id.  */
       {
@@ -2293,20 +2306,20 @@ process_send_signal (process, signo, current_group, nomsg)
 #ifdef pfa
        if (err == -1)
          gid = - XFASTINT (p->pid);
-#endif
+#endif /* ! defined (pfa) */
       }
       if (gid == -1)
        no_pgrp = 1;
       else
        gid = - gid;
+#else /* ! defined (TIOCGPGRP ) */
+      /* Can't select pgrps on this system, so we know that
+        the child itself heads the pgrp.  */
+      gid = - XFASTINT (p->pid);
+#endif /* ! defined (TIOCGPGRP ) */
     }
   else
     gid = - XFASTINT (p->pid);
-#else /* not using pgrps */
-  /* Can't select pgrps on this system, so we know that
-     the child itself heads the pgrp.  */
-  gid = - XFASTINT (p->pid);
-#endif /* not using pgrps */
 
   switch (signo)
     {
@@ -2319,7 +2332,7 @@ process_send_signal (process, signo, current_group, nomsg)
       if (!nomsg)
        status_notify ();
       break;
-#endif
+#endif /* ! defined (SIGCONT) */
     case SIGINT:
 #ifdef VMS
       send_process (proc, "\003", 1);  /* ^C */
@@ -2357,9 +2370,9 @@ process_send_signal (process, signo, current_group, nomsg)
       gid = - XFASTINT (p->pid);
       kill (gid, signo);
     }
-#else /* no TIOCSIGSEND */
+#else /* ! defined (TIOCSIGSEND) */
   EMACS_KILLPG (-gid, signo);
-#endif
+#endif /* ! defined (TIOCSIGSEND) */
 }
 
 DEFUN ("interrupt-process", Finterrupt_process, Sinterrupt_process, 0, 2, 0,
@@ -2603,8 +2616,8 @@ sigchld_handler (signo)
          
          /* If process has terminated, stop waiting for its output.  */
          if (WIFSIGNALED (w) || WIFEXITED (w))
-           if (p->infd)
-             FD_CLR (p->infd, &input_wait_mask);
+           if (XFASTINT (p->infd))
+             FD_CLR (XFASTINT (p->infd), &input_wait_mask);
        }
 
        /* There was no asynchronous process found for that id.  Check
@@ -2803,9 +2816,6 @@ t or pty (pty) or stream (socket connection).")
 #endif
 syms_of_process ()
 {
-#ifdef HAVE_PTYS
-  pty_process = intern ("pty");
-#endif
 #ifdef HAVE_SOCKETS
   stream_process = intern ("stream");
 #endif