diff options
Diffstat (limited to 'src/process.c')
| -rw-r--r-- | src/process.c | 74 |
1 files changed, 7 insertions, 67 deletions
diff --git a/src/process.c b/src/process.c index 51648187aff..0036ce595f5 100644 --- a/src/process.c +++ b/src/process.c | |||
| @@ -196,11 +196,9 @@ static EMACS_INT update_tick; | |||
| 196 | #ifndef NON_BLOCKING_CONNECT | 196 | #ifndef NON_BLOCKING_CONNECT |
| 197 | #ifdef HAVE_SELECT | 197 | #ifdef HAVE_SELECT |
| 198 | #if defined (HAVE_GETPEERNAME) || defined (GNU_LINUX) | 198 | #if defined (HAVE_GETPEERNAME) || defined (GNU_LINUX) |
| 199 | #if O_NONBLOCK || O_NDELAY | ||
| 200 | #if defined (EWOULDBLOCK) || defined (EINPROGRESS) | 199 | #if defined (EWOULDBLOCK) || defined (EINPROGRESS) |
| 201 | #define NON_BLOCKING_CONNECT | 200 | #define NON_BLOCKING_CONNECT |
| 202 | #endif /* EWOULDBLOCK || EINPROGRESS */ | 201 | #endif /* EWOULDBLOCK || EINPROGRESS */ |
| 203 | #endif /* O_NONBLOCK || O_NDELAY */ | ||
| 204 | #endif /* HAVE_GETPEERNAME || GNU_LINUX */ | 202 | #endif /* HAVE_GETPEERNAME || GNU_LINUX */ |
| 205 | #endif /* HAVE_SELECT */ | 203 | #endif /* HAVE_SELECT */ |
| 206 | #endif /* NON_BLOCKING_CONNECT */ | 204 | #endif /* NON_BLOCKING_CONNECT */ |
| @@ -639,13 +637,7 @@ allocate_pty (void) | |||
| 639 | #ifdef PTY_OPEN | 637 | #ifdef PTY_OPEN |
| 640 | PTY_OPEN; | 638 | PTY_OPEN; |
| 641 | #else /* no PTY_OPEN */ | 639 | #else /* no PTY_OPEN */ |
| 642 | { | 640 | fd = emacs_open (pty_name, O_RDWR | O_NONBLOCK, 0); |
| 643 | # if O_NONBLOCK | ||
| 644 | fd = emacs_open (pty_name, O_RDWR | O_NONBLOCK, 0); | ||
| 645 | # else | ||
| 646 | fd = emacs_open (pty_name, O_RDWR | O_NDELAY, 0); | ||
| 647 | # endif | ||
| 648 | } | ||
| 649 | #endif /* no PTY_OPEN */ | 641 | #endif /* no PTY_OPEN */ |
| 650 | 642 | ||
| 651 | if (fd >= 0) | 643 | if (fd >= 0) |
| @@ -1583,7 +1575,7 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir) | |||
| 1583 | int inchannel, outchannel; | 1575 | int inchannel, outchannel; |
| 1584 | pid_t pid; | 1576 | pid_t pid; |
| 1585 | int sv[2]; | 1577 | int sv[2]; |
| 1586 | #if !defined (WINDOWSNT) && defined (FD_CLOEXEC) | 1578 | #ifndef WINDOWSNT |
| 1587 | int wait_child_setup[2]; | 1579 | int wait_child_setup[2]; |
| 1588 | #endif | 1580 | #endif |
| 1589 | #ifdef SIGCHLD | 1581 | #ifdef SIGCHLD |
| @@ -1609,13 +1601,9 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir) | |||
| 1609 | #if ! defined (USG) || defined (USG_SUBTTY_WORKS) | 1601 | #if ! defined (USG) || defined (USG_SUBTTY_WORKS) |
| 1610 | /* On most USG systems it does not work to open the pty's tty here, | 1602 | /* On most USG systems it does not work to open the pty's tty here, |
| 1611 | then close it and reopen it in the child. */ | 1603 | then close it and reopen it in the child. */ |
| 1612 | #if O_NOCTTY | ||
| 1613 | /* Don't let this terminal become our controlling terminal | 1604 | /* Don't let this terminal become our controlling terminal |
| 1614 | (in case we don't have one). */ | 1605 | (in case we don't have one). */ |
| 1615 | forkout = forkin = emacs_open (pty_name, O_RDWR | O_NOCTTY, 0); | 1606 | forkout = forkin = emacs_open (pty_name, O_RDWR | O_NOCTTY, 0); |
| 1616 | #else | ||
| 1617 | forkout = forkin = emacs_open (pty_name, O_RDWR, 0); | ||
| 1618 | #endif | ||
| 1619 | if (forkin < 0) | 1607 | if (forkin < 0) |
| 1620 | report_file_error ("Opening pty", Qnil); | 1608 | report_file_error ("Opening pty", Qnil); |
| 1621 | #else | 1609 | #else |
| @@ -1644,7 +1632,7 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir) | |||
| 1644 | forkin = sv[0]; | 1632 | forkin = sv[0]; |
| 1645 | } | 1633 | } |
| 1646 | 1634 | ||
| 1647 | #if !defined (WINDOWSNT) && defined (FD_CLOEXEC) | 1635 | #ifndef WINDOWSNT |
| 1648 | { | 1636 | { |
| 1649 | int tem; | 1637 | int tem; |
| 1650 | 1638 | ||
| @@ -1663,15 +1651,8 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir) | |||
| 1663 | } | 1651 | } |
| 1664 | #endif | 1652 | #endif |
| 1665 | 1653 | ||
| 1666 | #if O_NONBLOCK | ||
| 1667 | fcntl (inchannel, F_SETFL, O_NONBLOCK); | 1654 | fcntl (inchannel, F_SETFL, O_NONBLOCK); |
| 1668 | fcntl (outchannel, F_SETFL, O_NONBLOCK); | 1655 | fcntl (outchannel, F_SETFL, O_NONBLOCK); |
| 1669 | #else | ||
| 1670 | #if O_NDELAY | ||
| 1671 | fcntl (inchannel, F_SETFL, O_NDELAY); | ||
| 1672 | fcntl (outchannel, F_SETFL, O_NDELAY); | ||
| 1673 | #endif | ||
| 1674 | #endif | ||
| 1675 | 1656 | ||
| 1676 | /* Record this as an active process, with its channels. | 1657 | /* Record this as an active process, with its channels. |
| 1677 | As a result, child_setup will close Emacs's side of the pipes. */ | 1658 | As a result, child_setup will close Emacs's side of the pipes. */ |
| @@ -1830,9 +1811,7 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir) | |||
| 1830 | pid = child_setup (xforkin, xforkout, xforkout, | 1811 | pid = child_setup (xforkin, xforkout, xforkout, |
| 1831 | new_argv, 1, encoded_current_dir); | 1812 | new_argv, 1, encoded_current_dir); |
| 1832 | #else /* not WINDOWSNT */ | 1813 | #else /* not WINDOWSNT */ |
| 1833 | #ifdef FD_CLOEXEC | ||
| 1834 | emacs_close (wait_child_setup[0]); | 1814 | emacs_close (wait_child_setup[0]); |
| 1835 | #endif | ||
| 1836 | child_setup (xforkin, xforkout, xforkout, | 1815 | child_setup (xforkin, xforkout, xforkout, |
| 1837 | new_argv, 1, encoded_current_dir); | 1816 | new_argv, 1, encoded_current_dir); |
| 1838 | #endif /* not WINDOWSNT */ | 1817 | #endif /* not WINDOWSNT */ |
| @@ -1891,7 +1870,7 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir) | |||
| 1891 | 1870 | ||
| 1892 | pset_tty_name (XPROCESS (process), lisp_pty_name); | 1871 | pset_tty_name (XPROCESS (process), lisp_pty_name); |
| 1893 | 1872 | ||
| 1894 | #if !defined (WINDOWSNT) && defined (FD_CLOEXEC) | 1873 | #ifndef WINDOWSNT |
| 1895 | /* Wait for child_setup to complete in case that vfork is | 1874 | /* Wait for child_setup to complete in case that vfork is |
| 1896 | actually defined as fork. The descriptor wait_child_setup[1] | 1875 | actually defined as fork. The descriptor wait_child_setup[1] |
| 1897 | of a pipe is closed at the child side either by close-on-exec | 1876 | of a pipe is closed at the child side either by close-on-exec |
| @@ -1928,13 +1907,9 @@ create_pty (Lisp_Object process) | |||
| 1928 | #if ! defined (USG) || defined (USG_SUBTTY_WORKS) | 1907 | #if ! defined (USG) || defined (USG_SUBTTY_WORKS) |
| 1929 | /* On most USG systems it does not work to open the pty's tty here, | 1908 | /* On most USG systems it does not work to open the pty's tty here, |
| 1930 | then close it and reopen it in the child. */ | 1909 | then close it and reopen it in the child. */ |
| 1931 | #if O_NOCTTY | ||
| 1932 | /* Don't let this terminal become our controlling terminal | 1910 | /* Don't let this terminal become our controlling terminal |
| 1933 | (in case we don't have one). */ | 1911 | (in case we don't have one). */ |
| 1934 | int forkout = emacs_open (pty_name, O_RDWR | O_NOCTTY, 0); | 1912 | int forkout = emacs_open (pty_name, O_RDWR | O_NOCTTY, 0); |
| 1935 | #else | ||
| 1936 | int forkout = emacs_open (pty_name, O_RDWR, 0); | ||
| 1937 | #endif | ||
| 1938 | if (forkout < 0) | 1913 | if (forkout < 0) |
| 1939 | report_file_error ("Opening pty", Qnil); | 1914 | report_file_error ("Opening pty", Qnil); |
| 1940 | #if defined (DONT_REOPEN_PTY) | 1915 | #if defined (DONT_REOPEN_PTY) |
| @@ -1948,15 +1923,8 @@ create_pty (Lisp_Object process) | |||
| 1948 | } | 1923 | } |
| 1949 | #endif /* HAVE_PTYS */ | 1924 | #endif /* HAVE_PTYS */ |
| 1950 | 1925 | ||
| 1951 | #if O_NONBLOCK | ||
| 1952 | fcntl (inchannel, F_SETFL, O_NONBLOCK); | 1926 | fcntl (inchannel, F_SETFL, O_NONBLOCK); |
| 1953 | fcntl (outchannel, F_SETFL, O_NONBLOCK); | 1927 | fcntl (outchannel, F_SETFL, O_NONBLOCK); |
| 1954 | #else | ||
| 1955 | #if O_NDELAY | ||
| 1956 | fcntl (inchannel, F_SETFL, O_NDELAY); | ||
| 1957 | fcntl (outchannel, F_SETFL, O_NDELAY); | ||
| 1958 | #endif | ||
| 1959 | #endif | ||
| 1960 | 1928 | ||
| 1961 | /* Record this as an active process, with its channels. | 1929 | /* Record this as an active process, with its channels. |
| 1962 | As a result, child_setup will close Emacs's side of the pipes. */ | 1930 | As a result, child_setup will close Emacs's side of the pipes. */ |
| @@ -2912,13 +2880,9 @@ usage: (make-network-process &rest ARGS) */) | |||
| 2912 | { | 2880 | { |
| 2913 | /* Don't support network sockets when non-blocking mode is | 2881 | /* Don't support network sockets when non-blocking mode is |
| 2914 | not available, since a blocked Emacs is not useful. */ | 2882 | not available, since a blocked Emacs is not useful. */ |
| 2915 | #if !O_NONBLOCK && !O_NDELAY | ||
| 2916 | error ("Network servers not supported"); | ||
| 2917 | #else | ||
| 2918 | is_server = 1; | 2883 | is_server = 1; |
| 2919 | if (TYPE_RANGED_INTEGERP (int, tem)) | 2884 | if (TYPE_RANGED_INTEGERP (int, tem)) |
| 2920 | backlog = XINT (tem); | 2885 | backlog = XINT (tem); |
| 2921 | #endif | ||
| 2922 | } | 2886 | } |
| 2923 | 2887 | ||
| 2924 | /* Make QCaddress an alias for :local (server) or :remote (client). */ | 2888 | /* Make QCaddress an alias for :local (server) or :remote (client). */ |
| @@ -3178,11 +3142,7 @@ usage: (make-network-process &rest ARGS) */) | |||
| 3178 | #ifdef NON_BLOCKING_CONNECT | 3142 | #ifdef NON_BLOCKING_CONNECT |
| 3179 | if (is_non_blocking_client) | 3143 | if (is_non_blocking_client) |
| 3180 | { | 3144 | { |
| 3181 | #if O_NONBLOCK | ||
| 3182 | ret = fcntl (s, F_SETFL, O_NONBLOCK); | 3145 | ret = fcntl (s, F_SETFL, O_NONBLOCK); |
| 3183 | #else | ||
| 3184 | ret = fcntl (s, F_SETFL, O_NDELAY); | ||
| 3185 | #endif | ||
| 3186 | if (ret < 0) | 3146 | if (ret < 0) |
| 3187 | { | 3147 | { |
| 3188 | xerrno = errno; | 3148 | xerrno = errno; |
| @@ -3395,13 +3355,7 @@ usage: (make-network-process &rest ARGS) */) | |||
| 3395 | 3355 | ||
| 3396 | chan_process[inch] = proc; | 3356 | chan_process[inch] = proc; |
| 3397 | 3357 | ||
| 3398 | #if O_NONBLOCK | ||
| 3399 | fcntl (inch, F_SETFL, O_NONBLOCK); | 3358 | fcntl (inch, F_SETFL, O_NONBLOCK); |
| 3400 | #else | ||
| 3401 | #if O_NDELAY | ||
| 3402 | fcntl (inch, F_SETFL, O_NDELAY); | ||
| 3403 | #endif | ||
| 3404 | #endif | ||
| 3405 | 3359 | ||
| 3406 | p = XPROCESS (proc); | 3360 | p = XPROCESS (proc); |
| 3407 | 3361 | ||
| @@ -4130,13 +4084,7 @@ server_accept_connection (Lisp_Object server, int channel) | |||
| 4130 | 4084 | ||
| 4131 | chan_process[s] = proc; | 4085 | chan_process[s] = proc; |
| 4132 | 4086 | ||
| 4133 | #if O_NONBLOCK | ||
| 4134 | fcntl (s, F_SETFL, O_NONBLOCK); | 4087 | fcntl (s, F_SETFL, O_NONBLOCK); |
| 4135 | #else | ||
| 4136 | #if O_NDELAY | ||
| 4137 | fcntl (s, F_SETFL, O_NDELAY); | ||
| 4138 | #endif | ||
| 4139 | #endif | ||
| 4140 | 4088 | ||
| 4141 | p = XPROCESS (proc); | 4089 | p = XPROCESS (proc); |
| 4142 | 4090 | ||
| @@ -4832,23 +4780,17 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd, | |||
| 4832 | else if (nread == -1 && errno == EWOULDBLOCK) | 4780 | else if (nread == -1 && errno == EWOULDBLOCK) |
| 4833 | ; | 4781 | ; |
| 4834 | #endif | 4782 | #endif |
| 4835 | /* ISC 4.1 defines both EWOULDBLOCK and O_NONBLOCK, | ||
| 4836 | and Emacs uses O_NONBLOCK, so what we get is EAGAIN. */ | ||
| 4837 | #if O_NONBLOCK | ||
| 4838 | else if (nread == -1 && errno == EAGAIN) | ||
| 4839 | ; | ||
| 4840 | #else | ||
| 4841 | #if O_NDELAY | ||
| 4842 | else if (nread == -1 && errno == EAGAIN) | 4783 | else if (nread == -1 && errno == EAGAIN) |
| 4843 | ; | 4784 | ; |
| 4785 | #ifdef WINDOWSNT | ||
| 4786 | /* FIXME: Is this special case still needed? */ | ||
| 4844 | /* Note that we cannot distinguish between no input | 4787 | /* Note that we cannot distinguish between no input |
| 4845 | available now and a closed pipe. | 4788 | available now and a closed pipe. |
| 4846 | With luck, a closed pipe will be accompanied by | 4789 | With luck, a closed pipe will be accompanied by |
| 4847 | subprocess termination and SIGCHLD. */ | 4790 | subprocess termination and SIGCHLD. */ |
| 4848 | else if (nread == 0 && !NETCONN_P (proc) && !SERIALCONN_P (proc)) | 4791 | else if (nread == 0 && !NETCONN_P (proc) && !SERIALCONN_P (proc)) |
| 4849 | ; | 4792 | ; |
| 4850 | #endif /* O_NDELAY */ | 4793 | #endif |
| 4851 | #endif /* O_NONBLOCK */ | ||
| 4852 | #ifdef HAVE_PTYS | 4794 | #ifdef HAVE_PTYS |
| 4853 | /* On some OSs with ptys, when the process on one end of | 4795 | /* On some OSs with ptys, when the process on one end of |
| 4854 | a pty exits, the other end gets an error reading with | 4796 | a pty exits, the other end gets an error reading with |
| @@ -7312,9 +7254,7 @@ init_process_emacs (void) | |||
| 7312 | #ifdef HAVE_GETSOCKNAME | 7254 | #ifdef HAVE_GETSOCKNAME |
| 7313 | ADD_SUBFEATURE (QCservice, Qt); | 7255 | ADD_SUBFEATURE (QCservice, Qt); |
| 7314 | #endif | 7256 | #endif |
| 7315 | #if O_NONBLOCK || O_NDELAY | ||
| 7316 | ADD_SUBFEATURE (QCserver, Qt); | 7257 | ADD_SUBFEATURE (QCserver, Qt); |
| 7317 | #endif | ||
| 7318 | 7258 | ||
| 7319 | for (sopt = socket_options; sopt->name; sopt++) | 7259 | for (sopt = socket_options; sopt->name; sopt++) |
| 7320 | subfeatures = pure_cons (intern_c_string (sopt->name), subfeatures); | 7260 | subfeatures = pure_cons (intern_c_string (sopt->name), subfeatures); |