Mercurial > emacs
comparison src/process.c @ 91367:c70e45a7acfd
Merge from emacs--devo--0
Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-324
| author | Miles Bader <miles@gnu.org> |
|---|---|
| date | Wed, 30 Jan 2008 07:57:28 +0000 |
| parents | 606f2d163a64 8f7e97005eef |
| children | f14242124fd7 |
comparison
equal
deleted
inserted
replaced
| 91366:86f3a8f0a3a6 | 91367:c70e45a7acfd |
|---|---|
| 76 /* TERM is a poor-man's SLIP, used on GNU/Linux. */ | 76 /* TERM is a poor-man's SLIP, used on GNU/Linux. */ |
| 77 #ifdef TERM | 77 #ifdef TERM |
| 78 #include <client.h> | 78 #include <client.h> |
| 79 #endif | 79 #endif |
| 80 | 80 |
| 81 /* On some systems, e.g. DGUX, inet_addr returns a 'struct in_addr'. */ | 81 /* On some systems, inet_addr returns a 'struct in_addr'. */ |
| 82 #ifdef HAVE_BROKEN_INET_ADDR | 82 #ifdef HAVE_BROKEN_INET_ADDR |
| 83 #define IN_ADDR struct in_addr | 83 #define IN_ADDR struct in_addr |
| 84 #define NUMERIC_ADDR_ERROR (numeric_addr.s_addr == -1) | 84 #define NUMERIC_ADDR_ERROR (numeric_addr.s_addr == -1) |
| 85 #else | 85 #else |
| 86 #define IN_ADDR unsigned long | 86 #define IN_ADDR unsigned long |
| 87 #define NUMERIC_ADDR_ERROR (numeric_addr == -1) | 87 #define NUMERIC_ADDR_ERROR (numeric_addr == -1) |
| 88 #endif | 88 #endif |
| 89 | 89 |
| 90 #if defined(BSD_SYSTEM) || defined(STRIDE) | 90 #if defined(BSD_SYSTEM) |
| 91 #include <sys/ioctl.h> | 91 #include <sys/ioctl.h> |
| 92 #if !defined (O_NDELAY) && defined (HAVE_PTYS) && !defined(USG5) | 92 #if !defined (O_NDELAY) && defined (HAVE_PTYS) && !defined(USG5) |
| 93 #include <fcntl.h> | 93 #include <fcntl.h> |
| 94 #endif /* HAVE_PTYS and no O_NDELAY */ | 94 #endif /* HAVE_PTYS and no O_NDELAY */ |
| 95 #endif /* BSD_SYSTEM || STRIDE */ | 95 #endif /* BSD_SYSTEM */ |
| 96 | 96 |
| 97 #ifdef BROKEN_O_NONBLOCK | 97 #ifdef BROKEN_O_NONBLOCK |
| 98 #undef O_NONBLOCK | 98 #undef O_NONBLOCK |
| 99 #endif /* BROKEN_O_NONBLOCK */ | 99 #endif /* BROKEN_O_NONBLOCK */ |
| 100 | 100 |
| 594 #ifdef PTY_TTY_NAME_SPRINTF | 594 #ifdef PTY_TTY_NAME_SPRINTF |
| 595 PTY_TTY_NAME_SPRINTF | 595 PTY_TTY_NAME_SPRINTF |
| 596 #else | 596 #else |
| 597 sprintf (pty_name, "/dev/tty%c%x", c, i); | 597 sprintf (pty_name, "/dev/tty%c%x", c, i); |
| 598 #endif /* no PTY_TTY_NAME_SPRINTF */ | 598 #endif /* no PTY_TTY_NAME_SPRINTF */ |
| 599 #ifndef UNIPLUS | |
| 600 if (access (pty_name, 6) != 0) | 599 if (access (pty_name, 6) != 0) |
| 601 { | 600 { |
| 602 emacs_close (fd); | 601 emacs_close (fd); |
| 603 # if !defined(IRIS) && !defined(__sgi) | 602 # if !defined(IRIS) && !defined(__sgi) |
| 604 continue; | 603 continue; |
| 605 # else | 604 # else |
| 606 return -1; | 605 return -1; |
| 607 # endif /* IRIS */ | 606 # endif /* IRIS */ |
| 608 } | 607 } |
| 609 #endif /* not UNIPLUS */ | |
| 610 setup_pty (fd); | 608 setup_pty (fd); |
| 611 return fd; | 609 return fd; |
| 612 } | 610 } |
| 613 } | 611 } |
| 614 return -1; | 612 return -1; |
| 1358 if (STRINGP (p->name) | 1356 if (STRINGP (p->name) |
| 1359 && ( i = SCHARS (p->name), (i > w_proc))) | 1357 && ( i = SCHARS (p->name), (i > w_proc))) |
| 1360 w_proc = i; | 1358 w_proc = i; |
| 1361 if (!NILP (p->buffer)) | 1359 if (!NILP (p->buffer)) |
| 1362 { | 1360 { |
| 1363 if (NILP (XBUFFER (p->buffer)->name) && w_buffer < 8) | 1361 if (NILP (XBUFFER (p->buffer)->name)) |
| 1364 w_buffer = 8; /* (Killed) */ | 1362 { |
| 1363 if (w_buffer < 8) | |
| 1364 w_buffer = 8; /* (Killed) */ | |
| 1365 } | |
| 1365 else if ((i = SCHARS (XBUFFER (p->buffer)->name), (i > w_buffer))) | 1366 else if ((i = SCHARS (XBUFFER (p->buffer)->name), (i > w_buffer))) |
| 1366 w_buffer = i; | 1367 w_buffer = i; |
| 1367 } | 1368 } |
| 1368 if (STRINGP (p->tty_name) | 1369 if (STRINGP (p->tty_name) |
| 1369 && (i = SCHARS (p->tty_name), (i > w_tty))) | 1370 && (i = SCHARS (p->tty_name), (i > w_tty))) |
| 1886 #else | 1887 #else |
| 1887 forkout = forkin = emacs_open (pty_name, O_RDWR, 0); | 1888 forkout = forkin = emacs_open (pty_name, O_RDWR, 0); |
| 1888 #endif | 1889 #endif |
| 1889 if (forkin < 0) | 1890 if (forkin < 0) |
| 1890 report_file_error ("Opening pty", Qnil); | 1891 report_file_error ("Opening pty", Qnil); |
| 1891 #if defined (RTU) || defined (UNIPLUS) || defined (DONT_REOPEN_PTY) | 1892 #if defined (DONT_REOPEN_PTY) |
| 1892 /* In the case that vfork is defined as fork, the parent process | 1893 /* In the case that vfork is defined as fork, the parent process |
| 1893 (Emacs) may send some data before the child process completes | 1894 (Emacs) may send some data before the child process completes |
| 1894 tty options setup. So we setup tty before forking. */ | 1895 tty options setup. So we setup tty before forking. */ |
| 1895 child_setup_tty (forkout); | 1896 child_setup_tty (forkout); |
| 1896 #endif /* RTU or UNIPLUS or DONT_REOPEN_PTY */ | 1897 #endif /* DONT_REOPEN_PTY */ |
| 1897 #else | 1898 #else |
| 1898 forkin = forkout = -1; | 1899 forkin = forkout = -1; |
| 1899 #endif /* not USG, or USG_SUBTTY_WORKS */ | 1900 #endif /* not USG, or USG_SUBTTY_WORKS */ |
| 1900 pty_flag = 1; | 1901 pty_flag = 1; |
| 1901 } | 1902 } |
| 1930 | 1931 |
| 1931 #if 0 | 1932 #if 0 |
| 1932 /* Replaced by close_process_descs */ | 1933 /* Replaced by close_process_descs */ |
| 1933 set_exclusive_use (inchannel); | 1934 set_exclusive_use (inchannel); |
| 1934 set_exclusive_use (outchannel); | 1935 set_exclusive_use (outchannel); |
| 1935 #endif | |
| 1936 | |
| 1937 /* Stride people say it's a mystery why this is needed | |
| 1938 as well as the O_NDELAY, but that it fails without this. */ | |
| 1939 #if defined (STRIDE) || (defined (pfa) && defined (HAVE_PTYS)) | |
| 1940 { | |
| 1941 int one = 1; | |
| 1942 ioctl (inchannel, FIONBIO, &one); | |
| 1943 } | |
| 1944 #endif | 1936 #endif |
| 1945 | 1937 |
| 1946 #ifdef O_NONBLOCK | 1938 #ifdef O_NONBLOCK |
| 1947 fcntl (inchannel, F_SETFL, O_NONBLOCK); | 1939 fcntl (inchannel, F_SETFL, O_NONBLOCK); |
| 1948 fcntl (outchannel, F_SETFL, O_NONBLOCK); | 1940 fcntl (outchannel, F_SETFL, O_NONBLOCK); |
| 1990 #else /* !POSIX_SIGNALS */ | 1982 #else /* !POSIX_SIGNALS */ |
| 1991 #ifdef SIGCHLD | 1983 #ifdef SIGCHLD |
| 1992 #ifdef BSD4_1 | 1984 #ifdef BSD4_1 |
| 1993 sighold (SIGCHLD); | 1985 sighold (SIGCHLD); |
| 1994 #else /* not BSD4_1 */ | 1986 #else /* not BSD4_1 */ |
| 1995 #if defined (BSD_SYSTEM) || defined (UNIPLUS) || defined (HPUX) | 1987 #if defined (BSD_SYSTEM) || defined (HPUX) |
| 1996 sigsetmask (sigmask (SIGCHLD)); | 1988 sigsetmask (sigmask (SIGCHLD)); |
| 1997 #else /* ordinary USG */ | 1989 #else /* ordinary USG */ |
| 1998 #if 0 | 1990 #if 0 |
| 1999 sigchld_deferred = 0; | 1991 sigchld_deferred = 0; |
| 2000 sigchld = signal (SIGCHLD, create_process_sigchld); | 1992 sigchld = signal (SIGCHLD, create_process_sigchld); |
| 2104 #endif | 2096 #endif |
| 2105 #endif | 2097 #endif |
| 2106 } | 2098 } |
| 2107 #endif /* TIOCNOTTY */ | 2099 #endif /* TIOCNOTTY */ |
| 2108 | 2100 |
| 2109 #if !defined (RTU) && !defined (UNIPLUS) && !defined (DONT_REOPEN_PTY) | 2101 #if !defined (DONT_REOPEN_PTY) |
| 2110 /*** There is a suggestion that this ought to be a | 2102 /*** There is a suggestion that this ought to be a |
| 2111 conditional on TIOCSPGRP, | 2103 conditional on TIOCSPGRP, |
| 2112 or !(defined (HAVE_SETSID) && defined (TIOCSCTTY)). | 2104 or !(defined (HAVE_SETSID) && defined (TIOCSCTTY)). |
| 2113 Trying the latter gave the wrong results on Debian GNU/Linux 1.1; | 2105 Trying the latter gave the wrong results on Debian GNU/Linux 1.1; |
| 2114 that system does seem to need this code, even though | 2106 that system does seem to need this code, even though |
| 2138 #ifdef SET_CHILD_PTY_PGRP | 2130 #ifdef SET_CHILD_PTY_PGRP |
| 2139 ioctl (xforkin, TIOCSPGRP, &pgrp); | 2131 ioctl (xforkin, TIOCSPGRP, &pgrp); |
| 2140 ioctl (xforkout, TIOCSPGRP, &pgrp); | 2132 ioctl (xforkout, TIOCSPGRP, &pgrp); |
| 2141 #endif | 2133 #endif |
| 2142 } | 2134 } |
| 2143 #endif /* not UNIPLUS and not RTU and not DONT_REOPEN_PTY */ | 2135 #endif /* not DONT_REOPEN_PTY */ |
| 2144 | 2136 |
| 2145 #ifdef SETUP_SLAVE_PTY | 2137 #ifdef SETUP_SLAVE_PTY |
| 2146 if (pty_flag) | 2138 if (pty_flag) |
| 2147 { | 2139 { |
| 2148 SETUP_SLAVE_PTY; | 2140 SETUP_SLAVE_PTY; |
| 2165 #else /* !POSIX_SIGNALS */ | 2157 #else /* !POSIX_SIGNALS */ |
| 2166 #ifdef SIGCHLD | 2158 #ifdef SIGCHLD |
| 2167 #ifdef BSD4_1 | 2159 #ifdef BSD4_1 |
| 2168 sigrelse (SIGCHLD); | 2160 sigrelse (SIGCHLD); |
| 2169 #else /* not BSD4_1 */ | 2161 #else /* not BSD4_1 */ |
| 2170 #if defined (BSD_SYSTEM) || defined (UNIPLUS) || defined (HPUX) | 2162 #if defined (BSD_SYSTEM) || defined (HPUX) |
| 2171 sigsetmask (SIGEMPTYMASK); | 2163 sigsetmask (SIGEMPTYMASK); |
| 2172 #else /* ordinary USG */ | 2164 #else /* ordinary USG */ |
| 2173 #if 0 | 2165 #if 0 |
| 2174 signal (SIGCHLD, sigchld); | 2166 signal (SIGCHLD, sigchld); |
| 2175 #endif | 2167 #endif |
| 2176 #endif /* ordinary USG */ | 2168 #endif /* ordinary USG */ |
| 2177 #endif /* not BSD4_1 */ | 2169 #endif /* not BSD4_1 */ |
| 2178 #endif /* SIGCHLD */ | 2170 #endif /* SIGCHLD */ |
| 2179 #endif /* !POSIX_SIGNALS */ | 2171 #endif /* !POSIX_SIGNALS */ |
| 2180 | 2172 |
| 2181 #if !defined (RTU) && !defined (UNIPLUS) && !defined (DONT_REOPEN_PTY) | 2173 #if !defined (DONT_REOPEN_PTY) |
| 2182 if (pty_flag) | 2174 if (pty_flag) |
| 2183 child_setup_tty (xforkout); | 2175 child_setup_tty (xforkout); |
| 2184 #endif /* not RTU and not UNIPLUS and not DONT_REOPEN_PTY */ | 2176 #endif /* not DONT_REOPEN_PTY */ |
| 2185 #ifdef WINDOWSNT | 2177 #ifdef WINDOWSNT |
| 2186 pid = child_setup (xforkin, xforkout, xforkout, | 2178 pid = child_setup (xforkin, xforkout, xforkout, |
| 2187 new_argv, 1, current_dir); | 2179 new_argv, 1, current_dir); |
| 2188 #else /* not WINDOWSNT */ | 2180 #else /* not WINDOWSNT */ |
| 2189 child_setup (xforkin, xforkout, xforkout, | 2181 child_setup (xforkin, xforkout, xforkout, |
| 2257 #else /* !POSIX_SIGNALS */ | 2249 #else /* !POSIX_SIGNALS */ |
| 2258 #ifdef SIGCHLD | 2250 #ifdef SIGCHLD |
| 2259 #ifdef BSD4_1 | 2251 #ifdef BSD4_1 |
| 2260 sigrelse (SIGCHLD); | 2252 sigrelse (SIGCHLD); |
| 2261 #else /* not BSD4_1 */ | 2253 #else /* not BSD4_1 */ |
| 2262 #if defined (BSD_SYSTEM) || defined (UNIPLUS) || defined (HPUX) | 2254 #if defined (BSD_SYSTEM) || defined (HPUX) |
| 2263 sigsetmask (SIGEMPTYMASK); | 2255 sigsetmask (SIGEMPTYMASK); |
| 2264 #else /* ordinary USG */ | 2256 #else /* ordinary USG */ |
| 2265 #if 0 | 2257 #if 0 |
| 2266 signal (SIGCHLD, sigchld); | 2258 signal (SIGCHLD, sigchld); |
| 2267 /* Now really handle any of these signals | 2259 /* Now really handle any of these signals |
| 4648 "__ultrix__"; the latter is only defined under GCC, but | 4640 "__ultrix__"; the latter is only defined under GCC, but |
| 4649 not by DEC's bundled CC. -JimB */ | 4641 not by DEC's bundled CC. -JimB */ |
| 4650 else if (xerrno == ENOMEM) | 4642 else if (xerrno == ENOMEM) |
| 4651 no_avail = 1; | 4643 no_avail = 1; |
| 4652 #endif | 4644 #endif |
| 4653 #ifdef ALLIANT | |
| 4654 /* This happens for no known reason on ALLIANT. | |
| 4655 I am guessing that this is the right response. -- RMS. */ | |
| 4656 else if (xerrno == EFAULT) | |
| 4657 no_avail = 1; | |
| 4658 #endif | |
| 4659 else if (xerrno == EBADF) | 4645 else if (xerrno == EBADF) |
| 4660 { | 4646 { |
| 4661 #ifdef AIX | 4647 #ifdef AIX |
| 4662 /* AIX doesn't handle PTY closure the same way BSD does. On AIX, | 4648 /* AIX doesn't handle PTY closure the same way BSD does. On AIX, |
| 4663 the child's closure of the pts gives the parent a SIGHUP, and | 4649 the child's closure of the pts gives the parent a SIGHUP, and |
| 4715 | 4701 |
| 4716 if (read_kbd != 0) | 4702 if (read_kbd != 0) |
| 4717 { | 4703 { |
| 4718 int old_timers_run = timers_run; | 4704 int old_timers_run = timers_run; |
| 4719 struct buffer *old_buffer = current_buffer; | 4705 struct buffer *old_buffer = current_buffer; |
| 4706 Lisp_Object old_window = selected_window; | |
| 4720 int leave = 0; | 4707 int leave = 0; |
| 4721 | 4708 |
| 4722 if (detect_input_pending_run_timers (do_display)) | 4709 if (detect_input_pending_run_timers (do_display)) |
| 4723 { | 4710 { |
| 4724 swallow_events (do_display); | 4711 swallow_events (do_display); |
| 4728 | 4715 |
| 4729 /* If a timer has run, this might have changed buffers | 4716 /* If a timer has run, this might have changed buffers |
| 4730 an alike. Make read_key_sequence aware of that. */ | 4717 an alike. Make read_key_sequence aware of that. */ |
| 4731 if (timers_run != old_timers_run | 4718 if (timers_run != old_timers_run |
| 4732 && waiting_for_user_input_p == -1 | 4719 && waiting_for_user_input_p == -1 |
| 4733 && old_buffer != current_buffer) | 4720 && (old_buffer != current_buffer |
| 4721 || !EQ (old_window, selected_window))) | |
| 4734 record_asynch_buffer_change (); | 4722 record_asynch_buffer_change (); |
| 4735 | 4723 |
| 4736 if (leave) | 4724 if (leave) |
| 4737 break; | 4725 break; |
| 4738 } | 4726 } |
