]> code.delx.au - gnu-emacs/blobdiff - src/process.c
* make-dist: Distribute some VMS files we got from Richard Levitte.
[gnu-emacs] / src / process.c
index 95be209f94c89dc676ada6f2e20e7d7ae87fb9f9..f383c95511af0a850c95691c5e08900d3c598001 100644 (file)
@@ -159,12 +159,14 @@ static Lisp_Object stream_process;
 #endif /* BSD or UNIPLUS or STRIDE */
 #endif /* no WAITTYPE */
 #else /* VMS */
-
-/* For the CMU PTY driver + */
-#define DCL_PROMPT "$ "
-/* This is a hack.  I have no idea what needs to go here, but this */
-/* will get it to compile.  We can fix it later.  rbr */
 #define WAITTYPE int
+#define WIFSTOPPED(w) 0
+#define WIFSIGNALED(w) 0
+#define WIFEXITED(w) ((w) != -1)
+#define WRETCODE(w) (w)
+#define WSTOPSIG(w) (w)
+#define WCOREDUMP(w) 0
+#define WTERMSIG(w) (w)
 #include <ssdef.h>
 #include <iodef.h>
 #include <clidef.h>
@@ -211,13 +213,6 @@ char *sys_siglist[] =
 #endif
 #endif /* VMS */
 
-#ifdef vipc
-
-#include "vipc.h"
-extern int comm_server;
-extern int net_listen_address;
-#endif /* vipc */
-
 /* t means use pty, nil means use a pipe,
    maybe other values to come.  */
 Lisp_Object Vprocess_connection_type;
@@ -364,7 +359,7 @@ status_message (status)
     {
       if (code == 0)
        return build_string ("finished\n");
-      string = Fint_to_string (make_number (code));
+      string = Fnumber_to_string (make_number (code));
       string2 = build_string (coredump ? " (core dumped)\n" : "\n");
       return concat2 (build_string ("exited abnormally with code "),
                      concat2 (string, string2));
@@ -1039,7 +1034,7 @@ Remaining arguments are strings to give program as arguments.")
   if (new_argv[0][0] != '/')
     {
       tem = Qnil;
-      openp (Vexec_path, program, "", &tem, 1);
+      openp (Vexec_path, program, EXEC_SUFFIXES, &tem, 1);
       if (NILP (tem))
        report_file_error ("Searching for program", Fcons (program, Qnil));
       new_argv[0] = XSTRING (tem)->data;
@@ -1534,7 +1529,7 @@ deactivate_process (proc)
       {
        VMS_PROC_STUFF *get_vms_process_pointer (), *vs;
        sys$dassgn (outchannel);
-       vs = get_vms_process_pointer (p->pid)
+       vs = get_vms_process_pointer (p->pid);
        if (vs)
          give_back_vms_process_stuff (vs);
       }
@@ -1655,11 +1650,16 @@ static int waiting_for_user_input_p;
      zero for no limit, or
      -1 means gobble data immediately available but don't wait for any.
 
+   microsecs is:
+     an additional duration to wait (if time_limit is greater than
+     zero), specified in millisec.
+
    read_kbd is a lisp value:
      0 to ignore keyboard input, or
      1 to return when input is available, or
-     -1 means caller will actually read the input, so don't throw to
+     -1 meaning caller will actually read the input, so don't throw to
        the quit handler, or
+     a cons cell, meaning wait wait until its car is non-nil, or
      a process object, meaning wait until something arrives from that
        process.  The return value is true iff we read some input from
        that process.
@@ -1686,6 +1686,7 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
   int wait_channel = 0;
   struct Lisp_Process *wait_proc = 0;
   int got_some_input = 0;
+  Lisp_Object *wait_for_cell = 0;
 
   FD_ZERO (&Available);
 
@@ -1698,6 +1699,13 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
       XFASTINT (read_kbd) = 0;
     }
 
+  /* If waiting for non-nil in a cell, record where.  */
+  if (XTYPE (read_kbd) == Lisp_Cons)
+    {
+      wait_for_cell = &XCONS (read_kbd)->car;
+      XFASTINT (read_kbd) = 0;
+    }
+
   waiting_for_user_input_p = XINT (read_kbd);
 
   /* Since we may need to wait several times,
@@ -1739,15 +1747,6 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
          EMACS_SET_SECS_USECS (timeout, 100000, 0);
        }
 
-      /* Cause C-g and alarm signals to take immediate action,
-        and cause input available signals to zero out timeout.
-
-        It is important that we do this before checking for process
-        activity.  If we get a SIGCHLD after the explicit checks for
-        process activity, timeout is the only way we will know.  */
-      if (XINT (read_kbd) < 0)
-       set_waiting_for_input (&timeout);
-
       /* If status of something has changed, and no input is
         available, notify the user of the change right away.  After
         this explicit check, we'll let the SIGCHLD handler zap
@@ -1760,6 +1759,15 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
            status_notify ();
        }
 
+      /* Cause C-g and alarm signals to take immediate action,
+        and cause input available signals to zero out timeout.
+
+        It is important that we do this before checking for process
+        activity.  If we get a SIGCHLD after the explicit checks for
+        process activity, timeout is the only way we will know.  */
+      if (XINT (read_kbd) < 0)
+       set_waiting_for_input (&timeout);
+
       /* Don't wait for output from a non-running process.  */
       if (wait_proc != 0 && !NILP (wait_proc->raw_status_low))
        update_status (wait_proc);
@@ -1833,9 +1841,15 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
          else
            error("select error: %s", sys_errlist[xerrno]);
        }
-#ifdef sun
+#if defined(sun) && !defined(USG5_4)
       else if (nfds > 0 && FD_ISSET (0, &Available) && interrupt_input)
-       /* System sometimes fails to deliver SIGIO.  */
+       /* System sometimes fails to deliver SIGIO.
+
+          David J. Mackenzie says that Emacs doesn't compile under
+          Solaris if this code is enabled, thus the USG5_4 in the CPP
+          conditional.  "I haven't noticed any ill effects so far.
+          If you find a Solaris expert somewhere, they might know
+          better." */
        kill (getpid (), SIGIO);
 #endif
 
@@ -1846,29 +1860,20 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
       if (XINT (read_kbd) && detect_input_pending ())
        break;
 
+      /* Exit now if the cell we're waiting for became non-nil.  */
+      if (wait_for_cell && ! NILP (*wait_for_cell))
+       break;
+
 #ifdef SIGIO
       /* If we think we have keyboard input waiting, but didn't get SIGIO
         go read it.  This can happen with X on BSD after logging out.
         In that case, there really is no input and no SIGIO,
         but select says there is input.  */
 
-      /*
-       if (XINT (read_kbd) && interrupt_input && (Available & fileno (stdin)))
-       */
       if (XINT (read_kbd) && interrupt_input && (FD_ISSET (fileno (stdin), &Available)))
        kill (0, SIGIO);
 #endif
 
-#ifdef vipc
-      /* Check for connection from other process */
-
-      if (Available & ChannelMask (comm_server))
-       {
-         Available &= ~(ChannelMask (comm_server));
-         create_commchan ();
-       }
-#endif /* vipc */
-
       if (! wait_proc)
        got_some_input |= nfds > 0;
 
@@ -1897,24 +1902,6 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
              if (NILP (proc))
                continue;
 
-#ifdef vipc
-             /* It's a command channel */
-             if (!NILP (XPROCESS (proc)->command_channel_p))
-               {
-                 ProcessCommChan (channel, proc);
-                 if (NILP (XPROCESS (proc)->command_channel_p))
-                   {
-                     /* It has ceased to be a command channel! */
-                     int bytes_available;
-                     if (ioctl (channel, FIONREAD, &bytes_available) < 0)
-                       bytes_available = 0;
-                     if (bytes_available)
-                       FD_SET (channel, &Available);
-                   }
-                 continue;
-               }
-#endif                         /* vipc */
-
              /* Read data from the process, starting with our
                 buffered-ahead character if we have one.  */
 
@@ -2342,12 +2329,12 @@ process_send_signal (process, signo, current_group, nomsg)
        case SIGINT:
          tcgetattr (XFASTINT (p->infd), &t);
          send_process (proc, &t.c_cc[VINTR], 1);
-         return Qnil;
+         return;
 
        case SIGQUIT:
          tcgetattr (XFASTINT (p->infd), &t);
          send_process (proc, &t.c_cc[VQUIT], 1);
-         return Qnil;
+         return;
 
        case SIGTSTP:
          tcgetattr (XFASTINT (p->infd), &t);
@@ -2356,7 +2343,7 @@ process_send_signal (process, signo, current_group, nomsg)
 #else
          send_process (proc, &t.c_cc[VSUSP], 1);
 #endif
-         return Qnil;
+         return;
        }
 
 #else /* ! HAVE_TERMIOS */
@@ -2593,6 +2580,13 @@ nil, indicating the current buffer's process.")
   Lisp_Object proc;
 
   proc = get_process (process);
+
+  /* Make sure the process is really alive.  */
+  if (! NILP (XPROCESS (proc)->raw_status_low))
+    update_status (XPROCESS (proc));
+  if (! EQ (XPROCESS (proc)->status, Qrun))
+    error ("Process %s not running", XSTRING (XPROCESS (proc)->name)->data);
+
   /* Sending a zero-length record is supposed to mean eof
      when TIOCREMOTE is turned on.  */
 #ifdef DID_REMOTE
@@ -2609,7 +2603,7 @@ nil, indicating the current buffer's process.")
   else
     {
       close (XPROCESS (proc)->outfd);
-      XFASTINT (XPROCESS (proc)->outfd) = open ("/dev/null", O_WRONLY);
+      XFASTINT (XPROCESS (proc)->outfd) = open (NULL_DEVICE, O_WRONLY);
     }
 #endif /* VMS */
 #endif /* did not do TOICREMOTE */
@@ -3167,6 +3161,8 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
        break;
     }
 
+  start_polling ();
+
   return 0;
 }