#define POLL_FOR_INPUT
#endif
+static Lisp_Object get_process ();
+static void exec_sentinel ();
+
+extern EMACS_TIME timer_check ();
+extern int timers_run;
+\f
/* Mask of bits indicating the descriptors that we wait for input on. */
static SELECT_TYPE input_wait_mask;
#define DATAGRAM_CONN_P(proc) (0)
#endif
-static Lisp_Object get_process ();
-static void exec_sentinel ();
-
-extern EMACS_TIME timer_check ();
-extern int timers_run;
-
/* Maximum number of bytes to send to a pty without an eof. */
static int pty_max_bytes;
+/* Nonzero means don't run process sentinels. This is used
+ when exiting. */
+int inhibit_sentinels;
+
#ifdef HAVE_PTYS
#ifdef HAVE_PTY_H
#include <pty.h>
register struct Lisp_Process *p;
char tembuf[300];
int w_proc, w_buffer, w_tty;
+ int exited = 0;
Lisp_Object i_status, i_buffer, i_tty, i_command;
w_proc = 4; /* Proc */
}
}
- if (EQ (symbol, Qsignal) || EQ (symbol, Qexit))
- remove_process (proc);
+ if (EQ (symbol, Qsignal) || EQ (symbol, Qexit) || EQ (symbol, Qclosed))
+ exited++;
Findent_to (i_buffer, minspace);
if (NILP (p->buffer))
insert_string ("\n");
}
}
+ if (exited)
+ status_notify (NULL);
return Qnil;
}
when not inside wait_reading_process_output. */
static int waiting_for_user_input_p;
+static Lisp_Object
+wait_reading_process_output_unwind (data)
+ Lisp_Object data;
+{
+ waiting_for_user_input_p = XINT (data);
+ return Qnil;
+}
+
/* This is here so breakpoints can be put on it. */
static void
wait_reading_process_output_1 ()
EMACS_TIME timeout, end_time;
int wait_channel = -1;
int got_some_input = 0;
- /* Either nil or a cons cell, the car of which is of interest and
- may be changed outside of this routine. */
- int saved_waiting_for_user_input_p = waiting_for_user_input_p;
+ int count = SPECPDL_INDEX ();
FD_ZERO (&Available);
#ifdef NON_BLOCKING_CONNECT
if (wait_proc != NULL)
wait_channel = XINT (wait_proc->infd);
+ record_unwind_protect (wait_reading_process_output_unwind,
+ make_number (waiting_for_user_input_p));
waiting_for_user_input_p = read_kbd;
/* Since we may need to wait several times,
} /* end for each file descriptor */
} /* end while exit conditions not met */
- waiting_for_user_input_p = saved_waiting_for_user_input_p;
+ unbind_to (count, Qnil);
/* If calling from keyboard input, do not quit
since we want to return C-g as an input character.
#endif
/* But do it only if the caller is actually going to read events.
Otherwise there's no need to make him wake up, and it could
- cause trouble (for example it would make Fsit_for return). */
+ cause trouble (for example it would make sit_for return). */
if (waiting_for_user_input_p == -1)
record_asynch_buffer_change ();
int outer_running_asynch_code = running_asynch_code;
int waiting = waiting_for_user_input_p;
+ if (inhibit_sentinels)
+ return;
+
/* No need to gcpro these, because all we do with them later
is test them for EQness, and none of them should be a string. */
odeactivate = Vdeactivate_mark;
#endif
/* But do it only if the caller is actually going to read events.
Otherwise there's no need to make him wake up, and it could
- cause trouble (for example it would make Fsit_for return). */
+ cause trouble (for example it would make sit_for return). */
if (waiting_for_user_input_p == -1)
record_asynch_buffer_change ();
{
register int i;
+ inhibit_sentinels = 0;
+
#ifdef SIGCHLD
#ifndef CANNOT_DUMP
if (! noninteractive || initialized)