#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>
#endif /* not IRIS */
#include "systime.h"
-#include "systerm.h"
+#include "systty.h"
#include "lisp.h"
#include "window.h"
#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>
/* 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;
{
*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);
}
}
}
\f
#ifdef HAVE_PTYS
-static int pty_process;
/* Open an available pty, returning a file descriptor.
Return -1 on failure.
{
#ifdef PTY_NAME_SPRINTF
PTY_NAME_SPRINTF
-#else
-#ifdef HPUX
- sprintf (pty_name, "/dev/ptym/pty%c%x", c, i);
-#else
-#ifdef RTU
- sprintf (pty_name, "/dev/pty%x", i);
#else
sprintf (pty_name, "/dev/pty%c%x", c, i);
-#endif /* not RTU */
-#endif /* not HPUX */
#endif /* no PTY_NAME_SPRINTF */
+#ifdef PTY_OPEN
+ PTY_OPEN;
+#else /* no PTY_OPEN */
#ifdef IRIS
/* Unusual IRIS code */
*ptyv = open ("/dev/ptc", O_RDWR | O_NDELAY, 0);
return -1;
if (fstat (fd, &stb) < 0)
return -1;
-#else
+#else /* not IRIS */
if (stat (pty_name, &stb) < 0)
{
failed_count++;
#else
fd = open (pty_name, O_RDWR | O_NDELAY, 0);
#endif
-#endif /* IRIS */
+#endif /* not IRIS */
+#endif /* no PTY_OPEN */
if (fd >= 0)
{
this avoids a nasty yet stupid bug in rlogins */
#ifdef PTY_TTY_NAME_SPRINTF
PTY_TTY_NAME_SPRINTF
-#else
- /* TODO: In version 19, make these special cases use the macro above. */
-#ifdef HPUX
- sprintf (pty_name, "/dev/pty/tty%c%x", c, i);
-#else
-#ifdef RTU
- sprintf (pty_name, "/dev/ttyp%x", i);
-#else
-#ifdef IRIS
- sprintf (pty_name, "/dev/ttyq%d", minor (stb.st_rdev));
#else
sprintf (pty_name, "/dev/tty%c%x", c, i);
-#endif /* not IRIS */
-#endif /* not RTU */
-#endif /* not HPUX */
#endif /* no PTY_TTY_NAME_SPRINTF */
#ifndef UNIPLUS
if (access (pty_name, 6) != 0)
return Qnil;
}
-/* This is how commands for the user decode process arguments */
+/* This is how commands for the user decode process arguments. It
+ accepts a process, a process name, a buffer, a buffer name, or nil.
+ Buffers denote the first process in the buffer, and nil denotes the
+ current buffer. */
Lisp_Object
get_process (name)
DEFUN ("delete-process", Fdelete_process, Sdelete_process, 1, 1, 0,
"Delete PROCESS: kill it and forget about it immediately.\n\
-PROCESS may be a process or the name of one, or a buffer name.")
+PROCESS may be a process, a buffer, the name of a process or buffer, or\n\
+nil, indicating the current buffer's process.")
(proc)
register Lisp_Object proc;
{
signal -- for a process that has got a fatal signal.\n\
open -- for a network stream connection that is open.\n\
closed -- for a network stream connection that is closed.\n\
-nil -- if arg is a process name and no such process exists.")
+nil -- if arg is a process name and no such process exists.\n\
+PROCESS may be a process, a buffer, the name of a process or buffer, or\n\
+nil, indicating the current buffer's process.")
/* command -- for a command channel opened to Emacs by another process.\n\
external -- for an i/o channel opened to Emacs by another process.\n\ */
(proc)
{
register struct Lisp_Process *p;
register Lisp_Object status;
- proc = Fget_process (proc);
+ proc = get_process (proc);
if (NILP (proc))
return proc;
p = XPROCESS (proc);
/* 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
#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 */
}
}
}
+ else
+ useconds = 0;
if (! NILP (timeout))
{
{
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. */
Available &= ~(ChannelMask (comm_server));
create_commchan ();
}
-#endif vipc
+#endif /* vipc */
if (! wait_proc)
got_some_input |= nfds > 0;
DEFUN ("process-send-region", Fprocess_send_region, Sprocess_send_region,
3, 3, 0,
"Send current contents of region as input to PROCESS.\n\
-PROCESS may be a process name or an actual process.\n\
+PROCESS may be a process, a buffer, the name of a process or buffer, or\n\
+nil, indicating the current buffer's process.\n\
Called from program, takes three arguments, PROCESS, START and END.\n\
If the region is more than 500 characters long,\n\
it is sent in several bunches. This may happen even for shorter regions.\n\
DEFUN ("process-send-string", Fprocess_send_string, Sprocess_send_string,
2, 2, 0,
"Send PROCESS the contents of STRING as input.\n\
-PROCESS may be a process name or an actual process.\n\
+PROCESS may be a process, a buffer, the name of a process or buffer, or\n\
+nil, indicating the current buffer's process.\n\
If STRING is more than 500 characters long,\n\
it is sent in several bunches. This may happen even for shorter strings.\n\
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;
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))
{
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. */
{
#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)
{
if (!nomsg)
status_notify ();
break;
-#endif
+#endif /* ! defined (SIGCONT) */
case SIGINT:
#ifdef VMS
send_process (proc, "\003", 1); /* ^C */
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,
"Interrupt process PROCESS. May be process or name of one.\n\
+PROCESS may be a process, a buffer, or the name of a process or buffer.\n\
Nil or no arg means current buffer's process.\n\
Second arg CURRENT-GROUP non-nil means send signal to\n\
the current process-group of the process's controlling terminal\n\
DEFUN ("process-send-eof", Fprocess_send_eof, Sprocess_send_eof, 0, 1, 0,
"Make PROCESS see end-of-file in its input.\n\
Eof comes after any text already sent to it.\n\
-nil or no arg means current buffer's process.")
+PROCESS may be a process, a buffer, the name of a process or buffer, or\n\
+nil, indicating the current buffer's process.")
(process)
Lisp_Object process;
{
/* 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
#endif
syms_of_process ()
{
-#ifdef HAVE_PTYS
- pty_process = intern ("pty");
-#endif
#ifdef HAVE_SOCKETS
stream_process = intern ("stream");
#endif