aboutsummaryrefslogtreecommitdiffstats
path: root/src/process.c
diff options
context:
space:
mode:
authorEli Zaretskii2012-11-17 20:00:16 +0200
committerEli Zaretskii2012-11-17 20:00:16 +0200
commitcf2d22b874ca2df0072e32ee641e8efffe4abd6d (patch)
tree1795142ec7861fc85c61adc90f03265b69041556 /src/process.c
parent3c4ca7155293ffc2d04708007131bcbc882d8913 (diff)
parent6ad30855c02908fdd99d9b11943719e185e65ee3 (diff)
downloademacs-cf2d22b874ca2df0072e32ee641e8efffe4abd6d.tar.gz
emacs-cf2d22b874ca2df0072e32ee641e8efffe4abd6d.zip
Merge from trunk.
Diffstat (limited to 'src/process.c')
-rw-r--r--src/process.c72
1 files changed, 18 insertions, 54 deletions
diff --git a/src/process.c b/src/process.c
index 43f0239d301..5fe6a6540f3 100644
--- a/src/process.c
+++ b/src/process.c
@@ -130,18 +130,6 @@ extern int sys_select (int, SELECT_TYPE *, SELECT_TYPE *, SELECT_TYPE *,
130 EMACS_TIME *, void *); 130 EMACS_TIME *, void *);
131#endif 131#endif
132 132
133/* This is for DOS_NT ports. FIXME: Remove this old portability cruft
134 by having DOS_NT ports implement waitpid instead of wait. Nowadays
135 POSIXish hosts all define waitpid, WNOHANG, and WUNTRACED, as these
136 have been standard since POSIX.1-1988. */
137#ifndef WNOHANG
138# undef waitpid
139# define waitpid(pid, status, options) wait (status)
140#endif
141#ifndef WUNTRACED
142# define WUNTRACED 0
143#endif
144
145/* Work around GCC 4.7.0 bug with strict overflow checking; see 133/* Work around GCC 4.7.0 bug with strict overflow checking; see
146 <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52904>. 134 <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52904>.
147 These lines can be removed once the GCC bug is fixed. */ 135 These lines can be removed once the GCC bug is fixed. */
@@ -208,7 +196,7 @@ static EMACS_INT update_tick;
208#ifndef NON_BLOCKING_CONNECT 196#ifndef NON_BLOCKING_CONNECT
209#ifdef HAVE_SELECT 197#ifdef HAVE_SELECT
210#if defined (HAVE_GETPEERNAME) || defined (GNU_LINUX) 198#if defined (HAVE_GETPEERNAME) || defined (GNU_LINUX)
211#if defined (O_NONBLOCK) || defined (O_NDELAY) 199#if O_NONBLOCK || O_NDELAY
212#if defined (EWOULDBLOCK) || defined (EINPROGRESS) 200#if defined (EWOULDBLOCK) || defined (EINPROGRESS)
213#define NON_BLOCKING_CONNECT 201#define NON_BLOCKING_CONNECT
214#endif /* EWOULDBLOCK || EINPROGRESS */ 202#endif /* EWOULDBLOCK || EINPROGRESS */
@@ -340,9 +328,6 @@ static struct sockaddr_and_len {
340#define DATAGRAM_CONN_P(proc) (0) 328#define DATAGRAM_CONN_P(proc) (0)
341#endif 329#endif
342 330
343/* Maximum number of bytes to send to a pty without an eof. */
344static int pty_max_bytes;
345
346/* These setters are used only in this file, so they can be private. */ 331/* These setters are used only in this file, so they can be private. */
347static void 332static void
348pset_buffer (struct Lisp_Process *p, Lisp_Object val) 333pset_buffer (struct Lisp_Process *p, Lisp_Object val)
@@ -655,7 +640,7 @@ allocate_pty (void)
655 PTY_OPEN; 640 PTY_OPEN;
656#else /* no PTY_OPEN */ 641#else /* no PTY_OPEN */
657 { 642 {
658# ifdef O_NONBLOCK 643# if O_NONBLOCK
659 fd = emacs_open (pty_name, O_RDWR | O_NONBLOCK, 0); 644 fd = emacs_open (pty_name, O_RDWR | O_NONBLOCK, 0);
660# else 645# else
661 fd = emacs_open (pty_name, O_RDWR | O_NDELAY, 0); 646 fd = emacs_open (pty_name, O_RDWR | O_NDELAY, 0);
@@ -672,7 +657,7 @@ allocate_pty (void)
672#else 657#else
673 sprintf (pty_name, "/dev/tty%c%x", c, i); 658 sprintf (pty_name, "/dev/tty%c%x", c, i);
674#endif /* no PTY_TTY_NAME_SPRINTF */ 659#endif /* no PTY_TTY_NAME_SPRINTF */
675 if (access (pty_name, 6) != 0) 660 if (faccessat (AT_FDCWD, pty_name, R_OK | W_OK, AT_EACCESS) != 0)
676 { 661 {
677 emacs_close (fd); 662 emacs_close (fd);
678# ifndef __sgi 663# ifndef __sgi
@@ -1624,7 +1609,7 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir)
1624#if ! defined (USG) || defined (USG_SUBTTY_WORKS) 1609#if ! defined (USG) || defined (USG_SUBTTY_WORKS)
1625 /* On most USG systems it does not work to open the pty's tty here, 1610 /* On most USG systems it does not work to open the pty's tty here,
1626 then close it and reopen it in the child. */ 1611 then close it and reopen it in the child. */
1627#ifdef O_NOCTTY 1612#if O_NOCTTY
1628 /* Don't let this terminal become our controlling terminal 1613 /* Don't let this terminal become our controlling terminal
1629 (in case we don't have one). */ 1614 (in case we don't have one). */
1630 forkout = forkin = emacs_open (pty_name, O_RDWR | O_NOCTTY, 0); 1615 forkout = forkin = emacs_open (pty_name, O_RDWR | O_NOCTTY, 0);
@@ -1678,11 +1663,11 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir)
1678 } 1663 }
1679#endif 1664#endif
1680 1665
1681#ifdef O_NONBLOCK 1666#if O_NONBLOCK
1682 fcntl (inchannel, F_SETFL, O_NONBLOCK); 1667 fcntl (inchannel, F_SETFL, O_NONBLOCK);
1683 fcntl (outchannel, F_SETFL, O_NONBLOCK); 1668 fcntl (outchannel, F_SETFL, O_NONBLOCK);
1684#else 1669#else
1685#ifdef O_NDELAY 1670#if O_NDELAY
1686 fcntl (inchannel, F_SETFL, O_NDELAY); 1671 fcntl (inchannel, F_SETFL, O_NDELAY);
1687 fcntl (outchannel, F_SETFL, O_NDELAY); 1672 fcntl (outchannel, F_SETFL, O_NDELAY);
1688#endif 1673#endif
@@ -1943,7 +1928,7 @@ create_pty (Lisp_Object process)
1943#if ! defined (USG) || defined (USG_SUBTTY_WORKS) 1928#if ! defined (USG) || defined (USG_SUBTTY_WORKS)
1944 /* On most USG systems it does not work to open the pty's tty here, 1929 /* On most USG systems it does not work to open the pty's tty here,
1945 then close it and reopen it in the child. */ 1930 then close it and reopen it in the child. */
1946#ifdef O_NOCTTY 1931#if O_NOCTTY
1947 /* Don't let this terminal become our controlling terminal 1932 /* Don't let this terminal become our controlling terminal
1948 (in case we don't have one). */ 1933 (in case we don't have one). */
1949 int forkout = emacs_open (pty_name, O_RDWR | O_NOCTTY, 0); 1934 int forkout = emacs_open (pty_name, O_RDWR | O_NOCTTY, 0);
@@ -1963,11 +1948,11 @@ create_pty (Lisp_Object process)
1963 } 1948 }
1964#endif /* HAVE_PTYS */ 1949#endif /* HAVE_PTYS */
1965 1950
1966#ifdef O_NONBLOCK 1951#if O_NONBLOCK
1967 fcntl (inchannel, F_SETFL, O_NONBLOCK); 1952 fcntl (inchannel, F_SETFL, O_NONBLOCK);
1968 fcntl (outchannel, F_SETFL, O_NONBLOCK); 1953 fcntl (outchannel, F_SETFL, O_NONBLOCK);
1969#else 1954#else
1970#ifdef O_NDELAY 1955#if O_NDELAY
1971 fcntl (inchannel, F_SETFL, O_NDELAY); 1956 fcntl (inchannel, F_SETFL, O_NDELAY);
1972 fcntl (outchannel, F_SETFL, O_NDELAY); 1957 fcntl (outchannel, F_SETFL, O_NDELAY);
1973#endif 1958#endif
@@ -2927,7 +2912,7 @@ usage: (make-network-process &rest ARGS) */)
2927 { 2912 {
2928 /* Don't support network sockets when non-blocking mode is 2913 /* Don't support network sockets when non-blocking mode is
2929 not available, since a blocked Emacs is not useful. */ 2914 not available, since a blocked Emacs is not useful. */
2930#if !defined (O_NONBLOCK) && !defined (O_NDELAY) 2915#if !O_NONBLOCK && !O_NDELAY
2931 error ("Network servers not supported"); 2916 error ("Network servers not supported");
2932#else 2917#else
2933 is_server = 1; 2918 is_server = 1;
@@ -3193,7 +3178,7 @@ usage: (make-network-process &rest ARGS) */)
3193#ifdef NON_BLOCKING_CONNECT 3178#ifdef NON_BLOCKING_CONNECT
3194 if (is_non_blocking_client) 3179 if (is_non_blocking_client)
3195 { 3180 {
3196#ifdef O_NONBLOCK 3181#if O_NONBLOCK
3197 ret = fcntl (s, F_SETFL, O_NONBLOCK); 3182 ret = fcntl (s, F_SETFL, O_NONBLOCK);
3198#else 3183#else
3199 ret = fcntl (s, F_SETFL, O_NDELAY); 3184 ret = fcntl (s, F_SETFL, O_NDELAY);
@@ -3410,10 +3395,10 @@ usage: (make-network-process &rest ARGS) */)
3410 3395
3411 chan_process[inch] = proc; 3396 chan_process[inch] = proc;
3412 3397
3413#ifdef O_NONBLOCK 3398#if O_NONBLOCK
3414 fcntl (inch, F_SETFL, O_NONBLOCK); 3399 fcntl (inch, F_SETFL, O_NONBLOCK);
3415#else 3400#else
3416#ifdef O_NDELAY 3401#if O_NDELAY
3417 fcntl (inch, F_SETFL, O_NDELAY); 3402 fcntl (inch, F_SETFL, O_NDELAY);
3418#endif 3403#endif
3419#endif 3404#endif
@@ -4145,10 +4130,10 @@ server_accept_connection (Lisp_Object server, int channel)
4145 4130
4146 chan_process[s] = proc; 4131 chan_process[s] = proc;
4147 4132
4148#ifdef O_NONBLOCK 4133#if O_NONBLOCK
4149 fcntl (s, F_SETFL, O_NONBLOCK); 4134 fcntl (s, F_SETFL, O_NONBLOCK);
4150#else 4135#else
4151#ifdef O_NDELAY 4136#if O_NDELAY
4152 fcntl (s, F_SETFL, O_NDELAY); 4137 fcntl (s, F_SETFL, O_NDELAY);
4153#endif 4138#endif
4154#endif 4139#endif
@@ -4849,11 +4834,11 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
4849#endif 4834#endif
4850 /* ISC 4.1 defines both EWOULDBLOCK and O_NONBLOCK, 4835 /* ISC 4.1 defines both EWOULDBLOCK and O_NONBLOCK,
4851 and Emacs uses O_NONBLOCK, so what we get is EAGAIN. */ 4836 and Emacs uses O_NONBLOCK, so what we get is EAGAIN. */
4852#ifdef O_NONBLOCK 4837#if O_NONBLOCK
4853 else if (nread == -1 && errno == EAGAIN) 4838 else if (nread == -1 && errno == EAGAIN)
4854 ; 4839 ;
4855#else 4840#else
4856#ifdef O_NDELAY 4841#if O_NDELAY
4857 else if (nread == -1 && errno == EAGAIN) 4842 else if (nread == -1 && errno == EAGAIN)
4858 ; 4843 ;
4859 /* Note that we cannot distinguish between no input 4844 /* Note that we cannot distinguish between no input
@@ -5532,19 +5517,6 @@ send_process (Lisp_Object proc, const char *buf, ptrdiff_t len,
5532 buf = SSDATA (object); 5517 buf = SSDATA (object);
5533 } 5518 }
5534 5519
5535 if (pty_max_bytes == 0)
5536 {
5537#if defined (HAVE_FPATHCONF) && defined (_PC_MAX_CANON)
5538 pty_max_bytes = fpathconf (p->outfd, _PC_MAX_CANON);
5539 if (pty_max_bytes < 0)
5540 pty_max_bytes = 250;
5541#else
5542 pty_max_bytes = 250;
5543#endif
5544 /* Deduct one, to leave space for the eof. */
5545 pty_max_bytes--;
5546 }
5547
5548 /* If there is already data in the write_queue, put the new data 5520 /* If there is already data in the write_queue, put the new data
5549 in the back of queue. Otherwise, ignore it. */ 5521 in the back of queue. Otherwise, ignore it. */
5550 if (!NILP (p->write_queue)) 5522 if (!NILP (p->write_queue))
@@ -6311,17 +6283,9 @@ record_child_status_change (pid_t pid, int w)
6311{ 6283{
6312#ifdef SIGCHLD 6284#ifdef SIGCHLD
6313 6285
6314# ifdef WNOHANG
6315 /* On POSIXish hosts, record at most one child only if we already 6286 /* On POSIXish hosts, record at most one child only if we already
6316 know one child that has exited. */ 6287 know one child that has exited. */
6317 bool record_at_most_one_child = 0 <= pid; 6288 bool record_at_most_one_child = 0 <= pid;
6318# else
6319 /* On DOS_NT (the only porting target that lacks WNOHANG),
6320 record the status of at most one child process, since the SIGCHLD
6321 handler must return right away. If any more processes want to
6322 signal us, we will get another signal. */
6323 bool record_at_most_one_child = 1;
6324# endif
6325 6289
6326 Lisp_Object tail; 6290 Lisp_Object tail;
6327 6291
@@ -7348,7 +7312,7 @@ init_process_emacs (void)
7348#ifdef HAVE_GETSOCKNAME 7312#ifdef HAVE_GETSOCKNAME
7349 ADD_SUBFEATURE (QCservice, Qt); 7313 ADD_SUBFEATURE (QCservice, Qt);
7350#endif 7314#endif
7351#if defined (O_NONBLOCK) || defined (O_NDELAY) 7315#if O_NONBLOCK || O_NDELAY
7352 ADD_SUBFEATURE (QCserver, Qt); 7316 ADD_SUBFEATURE (QCserver, Qt);
7353#endif 7317#endif
7354 7318