diff options
| author | Miles Bader | 2008-07-17 23:18:58 +0000 |
|---|---|---|
| committer | Miles Bader | 2008-07-17 23:18:58 +0000 |
| commit | 08b3caa982199bd7939d9d6877203ada5d0083b5 (patch) | |
| tree | eef15d8191132d316d1e1125cb7e2878a4782ca3 /src/process.c | |
| parent | 8d59c5ed4480037bcc953bd28a9165990fdd002e (diff) | |
| parent | 69955d31c4b59034d3429b14ca9f33ea102dde73 (diff) | |
| download | emacs-08b3caa982199bd7939d9d6877203ada5d0083b5.tar.gz emacs-08b3caa982199bd7939d9d6877203ada5d0083b5.zip | |
Merge from emacs--rel--22
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-1339
Diffstat (limited to 'src/process.c')
| -rw-r--r-- | src/process.c | 48 |
1 files changed, 39 insertions, 9 deletions
diff --git a/src/process.c b/src/process.c index 0a6e9f302be..0878051f733 100644 --- a/src/process.c +++ b/src/process.c | |||
| @@ -1851,6 +1851,9 @@ create_process (process, new_argv, current_dir) | |||
| 1851 | int inchannel, outchannel; | 1851 | int inchannel, outchannel; |
| 1852 | pid_t pid; | 1852 | pid_t pid; |
| 1853 | int sv[2]; | 1853 | int sv[2]; |
| 1854 | #if !defined (WINDOWSNT) && defined (FD_CLOEXEC) | ||
| 1855 | int wait_child_setup[2]; | ||
| 1856 | #endif | ||
| 1854 | #ifdef POSIX_SIGNALS | 1857 | #ifdef POSIX_SIGNALS |
| 1855 | sigset_t procmask; | 1858 | sigset_t procmask; |
| 1856 | sigset_t blocked; | 1859 | sigset_t blocked; |
| @@ -1924,6 +1927,25 @@ create_process (process, new_argv, current_dir) | |||
| 1924 | forkin = sv[0]; | 1927 | forkin = sv[0]; |
| 1925 | } | 1928 | } |
| 1926 | 1929 | ||
| 1930 | #if !defined (WINDOWSNT) && defined (FD_CLOEXEC) | ||
| 1931 | { | ||
| 1932 | int tem; | ||
| 1933 | |||
| 1934 | tem = pipe (wait_child_setup); | ||
| 1935 | if (tem < 0) | ||
| 1936 | report_file_error ("Creating pipe", Qnil); | ||
| 1937 | tem = fcntl (wait_child_setup[1], F_GETFD, 0); | ||
| 1938 | if (tem >= 0) | ||
| 1939 | tem = fcntl (wait_child_setup[1], F_SETFD, tem | FD_CLOEXEC); | ||
| 1940 | if (tem < 0) | ||
| 1941 | { | ||
| 1942 | emacs_close (wait_child_setup[0]); | ||
| 1943 | emacs_close (wait_child_setup[1]); | ||
| 1944 | report_file_error ("Setting file descriptor flags", Qnil); | ||
| 1945 | } | ||
| 1946 | } | ||
| 1947 | #endif | ||
| 1948 | |||
| 1927 | #if 0 | 1949 | #if 0 |
| 1928 | /* Replaced by close_process_descs */ | 1950 | /* Replaced by close_process_descs */ |
| 1929 | set_exclusive_use (inchannel); | 1951 | set_exclusive_use (inchannel); |
| @@ -2158,6 +2180,9 @@ create_process (process, new_argv, current_dir) | |||
| 2158 | pid = child_setup (xforkin, xforkout, xforkout, | 2180 | pid = child_setup (xforkin, xforkout, xforkout, |
| 2159 | new_argv, 1, current_dir); | 2181 | new_argv, 1, current_dir); |
| 2160 | #else /* not WINDOWSNT */ | 2182 | #else /* not WINDOWSNT */ |
| 2183 | #ifdef FD_CLOEXEC | ||
| 2184 | emacs_close (wait_child_setup[0]); | ||
| 2185 | #endif | ||
| 2161 | child_setup (xforkin, xforkout, xforkout, | 2186 | child_setup (xforkin, xforkout, xforkout, |
| 2162 | new_argv, 1, current_dir); | 2187 | new_argv, 1, current_dir); |
| 2163 | #endif /* not WINDOWSNT */ | 2188 | #endif /* not WINDOWSNT */ |
| @@ -2211,6 +2236,20 @@ create_process (process, new_argv, current_dir) | |||
| 2211 | else | 2236 | else |
| 2212 | #endif | 2237 | #endif |
| 2213 | XPROCESS (process)->tty_name = Qnil; | 2238 | XPROCESS (process)->tty_name = Qnil; |
| 2239 | |||
| 2240 | #if !defined (WINDOWSNT) && defined (FD_CLOEXEC) | ||
| 2241 | /* Wait for child_setup to complete in case that vfork is | ||
| 2242 | actually defined as fork. The descriptor wait_child_setup[1] | ||
| 2243 | of a pipe is closed at the child side either by close-on-exec | ||
| 2244 | on successful execvp or the _exit call in child_setup. */ | ||
| 2245 | { | ||
| 2246 | char dummy; | ||
| 2247 | |||
| 2248 | emacs_close (wait_child_setup[1]); | ||
| 2249 | emacs_read (wait_child_setup[0], &dummy, 1); | ||
| 2250 | emacs_close (wait_child_setup[0]); | ||
| 2251 | } | ||
| 2252 | #endif | ||
| 2214 | } | 2253 | } |
| 2215 | 2254 | ||
| 2216 | /* Restore the signal state whether vfork succeeded or not. | 2255 | /* Restore the signal state whether vfork succeeded or not. |
| @@ -4666,15 +4705,6 @@ wait_reading_process_output (time_limit, microsecs, read_kbd, do_display, | |||
| 4666 | #endif | 4705 | #endif |
| 4667 | 4706 | ||
| 4668 | Atemp = input_wait_mask; | 4707 | Atemp = input_wait_mask; |
| 4669 | #if 0 | ||
| 4670 | /* On Mac OS X 10.0, the SELECT system call always says input is | ||
| 4671 | present (for reading) at stdin, even when none is. This | ||
| 4672 | causes the call to SELECT below to return 1 and | ||
| 4673 | status_notify not to be called. As a result output of | ||
| 4674 | subprocesses are incorrectly discarded. | ||
| 4675 | */ | ||
| 4676 | FD_CLR (0, &Atemp); | ||
| 4677 | #endif | ||
| 4678 | IF_NON_BLOCKING_CONNECT (Ctemp = connect_wait_mask); | 4708 | IF_NON_BLOCKING_CONNECT (Ctemp = connect_wait_mask); |
| 4679 | 4709 | ||
| 4680 | EMACS_SET_SECS_USECS (timeout, 0, 0); | 4710 | EMACS_SET_SECS_USECS (timeout, 0, 0); |