X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/ee8e09af76dbcb18f33248d0d08b9321b900dd99..a03f91ada2cec963ec3e73e81dbc8fbd4e8e0cc9:/src/process.c diff --git a/src/process.c b/src/process.c index ca8cc24231..1afb701dd2 100644 --- a/src/process.c +++ b/src/process.c @@ -52,6 +52,9 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include #include +#ifdef NEED_NET_ERRNO_H +#include +#endif /* NEED_NET_ERRNO_H */ #endif /* HAVE_SOCKETS */ /* TERM is a poor-man's SLIP, used on Linux. */ @@ -205,9 +208,9 @@ int update_tick; #include "sysselect.h" -/* If we support X Windows, turn on the code to poll periodically +/* If we support a window system, turn on the code to poll periodically to detect C-g. It isn't actually used when doing interrupt input. */ -#ifdef HAVE_X_WINDOWS +#ifdef HAVE_WINDOW_SYSTEM #define POLL_FOR_INPUT #endif @@ -1080,8 +1083,6 @@ Remaining arguments are strings to give program as arguments.") #else /* not VMS */ new_argv = (unsigned char **) alloca ((nargs - 1) * sizeof (char *)); - program = Fexpand_file_name (program, Qnil); - /* If program file name is not absolute, search our path for it */ if (!IS_DIRECTORY_SEP (XSTRING (program)->data[0]) && !(XSTRING (program)->size > 1 @@ -1095,6 +1096,7 @@ Remaining arguments are strings to give program as arguments.") UNGCPRO; if (NILP (tem)) report_file_error ("Searching for program", Fcons (program, Qnil)); + tem = Fexpand_file_name (tem, Qnil); new_argv[0] = XSTRING (tem)->data; } else @@ -1195,9 +1197,19 @@ create_process (process, new_argv, current_dir) { int pid, inchannel, outchannel; int sv[2]; +#ifdef POSIX_SIGNALS + sigset_t procmask; + sigset_t blocked; + struct sigaction sigint_action; + struct sigaction sigquit_action; +#ifdef AIX + struct sigaction sighup_action; +#endif +#else /* !POSIX_SIGNALS */ #ifdef SIGCHLD SIGTYPE (*sigchld)(); #endif +#endif /* !POSIX_SIGNALS */ /* Use volatile to protect variables from being clobbered by longjmp. */ volatile int forkin, forkout; volatile int pty_flag = 0; @@ -1296,6 +1308,24 @@ create_process (process, new_argv, current_dir) /* Delay interrupts until we have a chance to store the new fork's pid in its process structure */ +#ifdef POSIX_SIGNALS + sigemptyset (&blocked); +#ifdef SIGCHLD + sigaddset (&blocked, SIGCHLD); +#endif +#ifdef HAVE_VFORK + /* On many hosts (e.g. Solaris 2.4), if a vforked child calls `signal', + this sets the parent's signal handlers as well as the child's. + So delay all interrupts whose handlers the child might munge, + and record the current handlers so they can be restored later. */ + sigaddset (&blocked, SIGINT ); sigaction (SIGINT , 0, &sigint_action ); + sigaddset (&blocked, SIGQUIT); sigaction (SIGQUIT, 0, &sigquit_action); +#ifdef AIX + sigaddset (&blocked, SIGHUP ); sigaction (SIGHUP , 0, &sighup_action ); +#endif +#endif /* HAVE_VFORK */ + sigprocmask (SIG_BLOCK, &blocked, &procmask); +#else /* !POSIX_SIGNALS */ #ifdef SIGCHLD #ifdef BSD4_1 sighold (SIGCHLD); @@ -1310,6 +1340,7 @@ create_process (process, new_argv, current_dir) #endif /* ordinary USG */ #endif /* not BSD4_1 */ #endif /* SIGCHLD */ +#endif /* !POSIX_SIGNALS */ FD_SET (inchannel, &input_wait_mask); FD_SET (inchannel, &non_keyboard_wait_mask); @@ -1453,6 +1484,13 @@ create_process (process, new_argv, current_dir) #endif #endif /* HAVE_PTYS */ + signal (SIGINT, SIG_DFL); + signal (SIGQUIT, SIG_DFL); + + /* Stop blocking signals in the child. */ +#ifdef POSIX_SIGNALS + sigprocmask (SIG_SETMASK, &procmask, 0); +#else /* !POSIX_SIGNALS */ #ifdef SIGCHLD #ifdef BSD4_1 sigrelse (SIGCHLD); @@ -1466,9 +1504,7 @@ create_process (process, new_argv, current_dir) #endif /* ordinary USG */ #endif /* not BSD4_1 */ #endif /* SIGCHLD */ - - signal (SIGINT, SIG_DFL); - signal (SIGQUIT, SIG_DFL); +#endif /* !POSIX_SIGNALS */ if (pty_flag) child_setup_tty (xforkout); @@ -1519,6 +1555,18 @@ create_process (process, new_argv, current_dir) #endif XPROCESS (process)->tty_name = Qnil; +#ifdef POSIX_SIGNALS +#ifdef HAVE_VFORK + /* Restore the parent's signal handlers. */ + sigaction (SIGINT, &sigint_action, 0); + sigaction (SIGQUIT, &sigquit_action, 0); +#ifdef AIX + sigaction (SIGHUP, &sighup_action, 0); +#endif +#endif /* HAVE_VFORK */ + /* Stop blocking signals in the parent. */ + sigprocmask (SIG_SETMASK, &procmask, 0); +#else /* !POSIX_SIGNALS */ #ifdef SIGCHLD #ifdef BSD4_1 sigrelse (SIGCHLD); @@ -1536,6 +1584,7 @@ create_process (process, new_argv, current_dir) #endif /* ordinary USG */ #endif /* not BSD4_1 */ #endif /* SIGCHLD */ +#endif /* !POSIX_SIGNALS */ } #endif /* not VMS */ @@ -1594,6 +1643,13 @@ Fourth arg SERVICE is name of the service desired, or an integer\n\ port = svc_info->s_port; } + /* Slow down polling to every ten seconds. + Some kernels have a bug which causes retrying connect to fail + after a connect. Polling can interfere with gethostbyname too. */ +#ifdef POLL_FOR_INPUT + bind_polling_period (10); +#endif + #ifndef TERM while (1) { @@ -1648,13 +1704,6 @@ Fourth arg SERVICE is name of the service desired, or an integer\n\ if (interrupt_input) unrequest_sigio (); - /* Slow down polling to every ten seconds. - Some kernels have a bug which causes retrying connect to fail - after a connect. */ -#ifdef POLL_FOR_INPUT - bind_polling_period (10); -#endif - loop: if (connect (s, (struct sockaddr *) &address, sizeof address) == -1 && errno != EISCONN) @@ -2385,12 +2434,17 @@ read_process_output (proc, channel) /* Handling the process output should not deactivate the mark. */ Vdeactivate_mark = odeactivate; +#if 0 /* Call record_asynch_buffer_change unconditionally, + because we might have changed minor modes or other things + that affect key bindings. */ if (! EQ (Fcurrent_buffer (), obuffer) || ! EQ (current_buffer->keymap, okeymap)) - record_asynch_buffer_change (); - - if (waiting_for_user_input_p) - prepare_menu_bars (); +#endif + /* But do it only if the caller is actually going to read events. + Otherwise there's no need to make him wake up, and it could + cause trouble (for example it would make Fsit_for return). */ + if (waiting_for_user_input_p == -1) + record_asynch_buffer_change (); #ifdef VMS start_vms_process_read (vs); @@ -3384,12 +3438,16 @@ exec_sentinel (proc, reason) restore_match_data (); Vdeactivate_mark = odeactivate; +#if 0 if (! EQ (Fcurrent_buffer (), obuffer) || ! EQ (current_buffer->keymap, okeymap)) - record_asynch_buffer_change (); +#endif + /* But do it only if the caller is actually going to read events. + Otherwise there's no need to make him wake up, and it could + cause trouble (for example it would make Fsit_for return). */ + if (waiting_for_user_input_p == -1) + record_asynch_buffer_change (); - if (waiting_for_user_input_p) - prepare_menu_bars (); unbind_to (count, Qnil); } @@ -3730,9 +3788,6 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display) /* It's infinite. */ timeout_p = 0; - /* This must come before stop_polling. */ - prepare_menu_bars (); - /* Turn off periodic alarms (in case they are in use) because the select emulator uses alarms. */ stop_polling ();