aboutsummaryrefslogtreecommitdiffstats
path: root/src/process.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/process.c')
-rw-r--r--src/process.c79
1 files changed, 26 insertions, 53 deletions
diff --git a/src/process.c b/src/process.c
index f80b5e80c76..c654369627d 100644
--- a/src/process.c
+++ b/src/process.c
@@ -25,12 +25,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
25 25
26#include <stdio.h> 26#include <stdio.h>
27#include <errno.h> 27#include <errno.h>
28#include <setjmp.h>
29#include <sys/types.h> /* Some typedefs are used in sys/file.h. */ 28#include <sys/types.h> /* Some typedefs are used in sys/file.h. */
30#include <sys/file.h> 29#include <sys/file.h>
31#include <sys/stat.h> 30#include <sys/stat.h>
32#include <setjmp.h>
33
34#include <unistd.h> 31#include <unistd.h>
35#include <fcntl.h> 32#include <fcntl.h>
36 33
@@ -75,6 +72,11 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
75#include <bsdtty.h> 72#include <bsdtty.h>
76#endif 73#endif
77 74
75#ifdef USG5_4
76# include <sys/stream.h>
77# include <sys/stropts.h>
78#endif
79
78#ifdef HAVE_RES_INIT 80#ifdef HAVE_RES_INIT
79#include <netinet/in.h> 81#include <netinet/in.h>
80#include <arpa/nameser.h> 82#include <arpa/nameser.h>
@@ -212,17 +214,13 @@ static EMACS_INT update_tick;
212 "non-destructive" select. So we require either native select, 214 "non-destructive" select. So we require either native select,
213 or emulation of select using FIONREAD. */ 215 or emulation of select using FIONREAD. */
214 216
215#ifdef BROKEN_DATAGRAM_SOCKETS 217#ifndef BROKEN_DATAGRAM_SOCKETS
216#undef DATAGRAM_SOCKETS 218# if defined HAVE_SELECT || defined USABLE_FIONREAD
217#else 219# if defined HAVE_SENDTO && defined HAVE_RECVFROM && defined EMSGSIZE
218#ifndef DATAGRAM_SOCKETS 220# define DATAGRAM_SOCKETS
219#if defined (HAVE_SELECT) || defined (FIONREAD) 221# endif
220#if defined (HAVE_SENDTO) && defined (HAVE_RECVFROM) && defined (EMSGSIZE) 222# endif
221#define DATAGRAM_SOCKETS 223#endif
222#endif /* HAVE_SENDTO && HAVE_RECVFROM && EMSGSIZE */
223#endif /* HAVE_SELECT || FIONREAD */
224#endif /* DATAGRAM_SOCKETS */
225#endif /* BROKEN_DATAGRAM_SOCKETS */
226 224
227#if defined HAVE_LOCAL_SOCKETS && defined DATAGRAM_SOCKETS 225#if defined HAVE_LOCAL_SOCKETS && defined DATAGRAM_SOCKETS
228# define HAVE_SEQPACKET 226# define HAVE_SEQPACKET
@@ -251,7 +249,7 @@ static int process_output_skip;
251#endif 249#endif
252 250
253static void create_process (Lisp_Object, char **, Lisp_Object); 251static void create_process (Lisp_Object, char **, Lisp_Object);
254#ifdef SIGIO 252#ifdef USABLE_SIGIO
255static int keyboard_bit_set (SELECT_TYPE *); 253static int keyboard_bit_set (SELECT_TYPE *);
256#endif 254#endif
257static void deactivate_process (Lisp_Object); 255static void deactivate_process (Lisp_Object);
@@ -1611,14 +1609,10 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir)
1611#if !defined (WINDOWSNT) && defined (FD_CLOEXEC) 1609#if !defined (WINDOWSNT) && defined (FD_CLOEXEC)
1612 int wait_child_setup[2]; 1610 int wait_child_setup[2];
1613#endif 1611#endif
1612#ifdef SIGCHLD
1614 sigset_t blocked, procmask; 1613 sigset_t blocked, procmask;
1615 struct sigaction sigint_action;
1616 struct sigaction sigquit_action;
1617 struct sigaction sigpipe_action;
1618#ifdef AIX
1619 struct sigaction sighup_action;
1620#endif 1614#endif
1621 /* Use volatile to protect variables from being clobbered by longjmp. */ 1615 /* Use volatile to protect variables from being clobbered by vfork. */
1622 volatile int forkin, forkout; 1616 volatile int forkin, forkout;
1623 volatile int pty_flag = 0; 1617 volatile int pty_flag = 0;
1624 1618
@@ -1710,25 +1704,13 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir)
1710 XPROCESS (process)->pty_flag = pty_flag; 1704 XPROCESS (process)->pty_flag = pty_flag;
1711 pset_status (XPROCESS (process), Qrun); 1705 pset_status (XPROCESS (process), Qrun);
1712 1706
1707#ifdef SIGCHLD
1713 /* Delay interrupts until we have a chance to store 1708 /* Delay interrupts until we have a chance to store
1714 the new fork's pid in its process structure */ 1709 the new fork's pid in its process structure */
1715 sigemptyset (&blocked); 1710 sigemptyset (&blocked);
1716#ifdef SIGCHLD
1717 sigaddset (&blocked, SIGCHLD); 1711 sigaddset (&blocked, SIGCHLD);
1718#endif
1719#ifdef HAVE_WORKING_VFORK
1720 /* On many hosts (e.g. Solaris 2.4), if a vforked child calls `signal',
1721 this sets the parent's signal handlers as well as the child's.
1722 So delay all interrupts whose handlers the child might munge,
1723 and record the current handlers so they can be restored later. */
1724 sigaddset (&blocked, SIGINT ); sigaction (SIGINT , 0, &sigint_action );
1725 sigaddset (&blocked, SIGQUIT); sigaction (SIGQUIT, 0, &sigquit_action);
1726 sigaddset (&blocked, SIGPIPE); sigaction (SIGPIPE, 0, &sigpipe_action);
1727#ifdef AIX
1728 sigaddset (&blocked, SIGHUP ); sigaction (SIGHUP , 0, &sighup_action );
1729#endif
1730#endif /* HAVE_WORKING_VFORK */
1731 pthread_sigmask (SIG_BLOCK, &blocked, &procmask); 1712 pthread_sigmask (SIG_BLOCK, &blocked, &procmask);
1713#endif
1732 1714
1733 FD_SET (inchannel, &input_wait_mask); 1715 FD_SET (inchannel, &input_wait_mask);
1734 FD_SET (inchannel, &non_keyboard_wait_mask); 1716 FD_SET (inchannel, &non_keyboard_wait_mask);
@@ -1881,8 +1863,10 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir)
1881 in the child. */ 1863 in the child. */
1882 signal (SIGPIPE, SIG_DFL); 1864 signal (SIGPIPE, SIG_DFL);
1883 1865
1866#ifdef SIGCHLD
1884 /* Stop blocking signals in the child. */ 1867 /* Stop blocking signals in the child. */
1885 pthread_sigmask (SIG_SETMASK, &procmask, 0); 1868 pthread_sigmask (SIG_SETMASK, &procmask, 0);
1869#endif
1886 1870
1887 if (pty_flag) 1871 if (pty_flag)
1888 child_setup_tty (xforkout); 1872 child_setup_tty (xforkout);
@@ -1961,19 +1945,10 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir)
1961#endif 1945#endif
1962 } 1946 }
1963 1947
1964 /* Restore the signal state whether vfork succeeded or not. 1948#ifdef SIGCHLD
1965 (We will signal an error, below, if it failed.) */
1966#ifdef HAVE_WORKING_VFORK
1967 /* Restore the parent's signal handlers. */
1968 sigaction (SIGINT, &sigint_action, 0);
1969 sigaction (SIGQUIT, &sigquit_action, 0);
1970 sigaction (SIGPIPE, &sigpipe_action, 0);
1971#ifdef AIX
1972 sigaction (SIGHUP, &sighup_action, 0);
1973#endif
1974#endif /* HAVE_WORKING_VFORK */
1975 /* Stop blocking signals in the parent. */ 1949 /* Stop blocking signals in the parent. */
1976 pthread_sigmask (SIG_SETMASK, &procmask, 0); 1950 pthread_sigmask (SIG_SETMASK, &procmask, 0);
1951#endif
1977 1952
1978 /* Now generate the error if vfork failed. */ 1953 /* Now generate the error if vfork failed. */
1979 if (pid < 0) 1954 if (pid < 0)
@@ -4397,10 +4372,8 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
4397 Otherwise, do pending quit if requested. */ 4372 Otherwise, do pending quit if requested. */
4398 if (read_kbd >= 0) 4373 if (read_kbd >= 0)
4399 QUIT; 4374 QUIT;
4400#ifdef SYNC_INPUT
4401 else 4375 else
4402 process_pending_signals (); 4376 process_pending_signals ();
4403#endif
4404 4377
4405 /* Exit now if the cell we're waiting for became non-nil. */ 4378 /* Exit now if the cell we're waiting for became non-nil. */
4406 if (! NILP (wait_for_cell) && ! NILP (XCAR (wait_for_cell))) 4379 if (! NILP (wait_for_cell) && ! NILP (XCAR (wait_for_cell)))
@@ -4836,7 +4809,7 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
4836 if (! NILP (wait_for_cell) && ! NILP (XCAR (wait_for_cell))) 4809 if (! NILP (wait_for_cell) && ! NILP (XCAR (wait_for_cell)))
4837 break; 4810 break;
4838 4811
4839#ifdef SIGIO 4812#ifdef USABLE_SIGIO
4840 /* If we think we have keyboard input waiting, but didn't get SIGIO, 4813 /* If we think we have keyboard input waiting, but didn't get SIGIO,
4841 go read it. This can happen with X on BSD after logging out. 4814 go read it. This can happen with X on BSD after logging out.
4842 In that case, there really is no input and no SIGIO, 4815 In that case, there really is no input and no SIGIO,
@@ -5420,7 +5393,7 @@ read_process_output (Lisp_Object proc, register int channel)
5420 5393
5421/* Sending data to subprocess */ 5394/* Sending data to subprocess */
5422 5395
5423static jmp_buf send_process_frame; 5396static sys_jmp_buf send_process_frame;
5424static Lisp_Object process_sent_to; 5397static Lisp_Object process_sent_to;
5425 5398
5426static _Noreturn void 5399static _Noreturn void
@@ -5430,7 +5403,7 @@ handle_pipe_signal (int sig)
5430 sigemptyset (&unblocked); 5403 sigemptyset (&unblocked);
5431 sigaddset (&unblocked, SIGPIPE); 5404 sigaddset (&unblocked, SIGPIPE);
5432 pthread_sigmask (SIG_UNBLOCK, &unblocked, 0); 5405 pthread_sigmask (SIG_UNBLOCK, &unblocked, 0);
5433 _longjmp (send_process_frame, 1); 5406 sys_longjmp (send_process_frame, 1);
5434} 5407}
5435 5408
5436static void 5409static void
@@ -5639,7 +5612,7 @@ send_process (volatile Lisp_Object proc, const char *volatile buf,
5639 /* 2000-09-21: Emacs 20.7, sparc-sun-solaris-2.6, GCC 2.95.2, 5612 /* 2000-09-21: Emacs 20.7, sparc-sun-solaris-2.6, GCC 2.95.2,
5640 CFLAGS="-g -O": The value of the parameter `proc' is clobbered 5613 CFLAGS="-g -O": The value of the parameter `proc' is clobbered
5641 when returning with longjmp despite being declared volatile. */ 5614 when returning with longjmp despite being declared volatile. */
5642 if (!_setjmp (send_process_frame)) 5615 if (!sys_setjmp (send_process_frame))
5643 { 5616 {
5644 p = XPROCESS (proc); /* Repair any setjmp clobbering. */ 5617 p = XPROCESS (proc); /* Repair any setjmp clobbering. */
5645 process_sent_to = proc; 5618 process_sent_to = proc;
@@ -6853,7 +6826,7 @@ delete_gpm_wait_descriptor (int desc)
6853 6826
6854# endif 6827# endif
6855 6828
6856# ifdef SIGIO 6829# ifdef USABLE_SIGIO
6857 6830
6858/* Return nonzero if *MASK has a bit set 6831/* Return nonzero if *MASK has a bit set
6859 that corresponds to one of the keyboard input descriptors. */ 6832 that corresponds to one of the keyboard input descriptors. */