Mercurial > emacs
comparison src/process.c @ 96774:3760da9fe15e
Merge from emacs--rel--22
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-1339
author | Miles Bader <miles@gnu.org> |
---|---|
date | Thu, 17 Jul 2008 23:18:58 +0000 |
parents | 1e0b67e40d48 a6adb4611f10 |
children | c06568fd3844 |
comparison
equal
deleted
inserted
replaced
96773:8b4d07d37cc5 | 96774:3760da9fe15e |
---|---|
1849 Lisp_Object current_dir; | 1849 Lisp_Object current_dir; |
1850 { | 1850 { |
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; |
1857 struct sigaction sigint_action; | 1860 struct sigaction sigint_action; |
1858 struct sigaction sigquit_action; | 1861 struct sigaction sigquit_action; |
1921 report_file_error ("Creating pipe", Qnil); | 1924 report_file_error ("Creating pipe", Qnil); |
1922 } | 1925 } |
1923 outchannel = sv[1]; | 1926 outchannel = sv[1]; |
1924 forkin = sv[0]; | 1927 forkin = sv[0]; |
1925 } | 1928 } |
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 | |
1926 | 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); |
1930 set_exclusive_use (outchannel); | 1952 set_exclusive_use (outchannel); |
2156 #endif /* not DONT_REOPEN_PTY */ | 2178 #endif /* not DONT_REOPEN_PTY */ |
2157 #ifdef WINDOWSNT | 2179 #ifdef WINDOWSNT |
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 */ |
2164 } | 2189 } |
2165 environ = save_environ; | 2190 environ = save_environ; |
2209 if (pty_flag) | 2234 if (pty_flag) |
2210 XPROCESS (process)->tty_name = build_string (pty_name); | 2235 XPROCESS (process)->tty_name = build_string (pty_name); |
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. |
2217 (We will signal an error, below, if it failed.) */ | 2256 (We will signal an error, below, if it failed.) */ |
2218 #ifdef POSIX_SIGNALS | 2257 #ifdef POSIX_SIGNALS |
4664 #ifdef NON_BLOCKING_CONNECT | 4703 #ifdef NON_BLOCKING_CONNECT |
4665 SELECT_TYPE Ctemp; | 4704 SELECT_TYPE Ctemp; |
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); |
4681 if ((select (max (max (max_process_desc, max_keyboard_desc), | 4711 if ((select (max (max (max_process_desc, max_keyboard_desc), |
4682 max_gpm_desc) + 1, | 4712 max_gpm_desc) + 1, |