diff options
| author | Paul Eggert | 2013-06-22 12:01:47 -0700 |
|---|---|---|
| committer | Paul Eggert | 2013-06-22 12:01:47 -0700 |
| commit | 0dfeed58d3244487a545bb4d4e19658eb299937b (patch) | |
| tree | 8d63fe126e9983af886f1a8e3d4bbd5f38282633 /src | |
| parent | f86852b4a3c34213f93fc5de5cb1632b49962023 (diff) | |
| download | emacs-0dfeed58d3244487a545bb4d4e19658eb299937b.tar.gz emacs-0dfeed58d3244487a545bb4d4e19658eb299937b.zip | |
Clean up SIGCHLD handling a bit.
* process.c, process.h (catch_child_signal):
Now always extern, even if !NS_IMPL_GNUSTEP.
* process.c (catch_child_signal): Move glib tickler here from
init_process_emacs, so that it's done earlier in Emacs
initialization. Also move the noninteractive && !initialized
check here from init_process_emacs. This is all a bit cleaner for
GNUish platforms, and I hope it works around the Cygwin bug.
* sysdep.c (init_signals): Invoke catch_child_signal here, so
that glib signal handling is tickled before glib creates threads.
Fixes: debbugs:14569
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 11 | ||||
| -rw-r--r-- | src/process.c | 35 | ||||
| -rw-r--r-- | src/process.h | 2 | ||||
| -rw-r--r-- | src/sysdep.c | 2 |
4 files changed, 32 insertions, 18 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 36709eb5107..202331dac53 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,5 +1,16 @@ | |||
| 1 | 2013-06-22 Paul Eggert <eggert@cs.ucla.edu> | 1 | 2013-06-22 Paul Eggert <eggert@cs.ucla.edu> |
| 2 | 2 | ||
| 3 | Clean up SIGCHLD handling a bit (Bug#14569). | ||
| 4 | * process.c, process.h (catch_child_signal): | ||
| 5 | Now always extern, even if !NS_IMPL_GNUSTEP. | ||
| 6 | * process.c (catch_child_signal): Move glib tickler here from | ||
| 7 | init_process_emacs, so that it's done earlier in Emacs | ||
| 8 | initialization. Also move the noninteractive && !initialized | ||
| 9 | check here from init_process_emacs. This is all a bit cleaner for | ||
| 10 | GNUish platforms, and I hope it works around the Cygwin bug. | ||
| 11 | * sysdep.c (init_signals): Invoke catch_child_signal here, so | ||
| 12 | that glib signal handling is tickled before glib creates threads. | ||
| 13 | |||
| 3 | * process.c (wait_reading_process_output): Avoid int overflow | 14 | * process.c (wait_reading_process_output): Avoid int overflow |
| 4 | when reading more than 2 GiB total from a process. | 15 | when reading more than 2 GiB total from a process. |
| 5 | 16 | ||
diff --git a/src/process.c b/src/process.c index 0631cb732bf..3e31dede4c2 100644 --- a/src/process.c +++ b/src/process.c | |||
| @@ -7060,13 +7060,29 @@ integer or floating point values. | |||
| 7060 | return system_process_attributes (pid); | 7060 | return system_process_attributes (pid); |
| 7061 | } | 7061 | } |
| 7062 | 7062 | ||
| 7063 | #ifndef NS_IMPL_GNUSTEP | 7063 | /* Arrange to catch SIGCHLD if needed. */ |
| 7064 | static | 7064 | |
| 7065 | #endif | ||
| 7066 | void | 7065 | void |
| 7067 | catch_child_signal (void) | 7066 | catch_child_signal (void) |
| 7068 | { | 7067 | { |
| 7069 | struct sigaction action, old_action; | 7068 | struct sigaction action, old_action; |
| 7069 | |||
| 7070 | #if !defined CANNOT_DUMP | ||
| 7071 | if (noninteractive && !initialized) | ||
| 7072 | return; | ||
| 7073 | #endif | ||
| 7074 | |||
| 7075 | #if defined HAVE_GLIB && !defined WINDOWSNT | ||
| 7076 | /* Tickle glib's child-handling code. Ask glib to wait for Emacs itself; | ||
| 7077 | this should always fail, but is enough to initialize glib's | ||
| 7078 | private SIGCHLD handler, allowing the code below to copy it into | ||
| 7079 | LIB_CHILD_HANDLER. | ||
| 7080 | |||
| 7081 | Do this early in Emacs initialization, before glib creates | ||
| 7082 | threads, to avoid race condition bugs in Cygwin glib. */ | ||
| 7083 | g_source_unref (g_child_watch_source_new (getpid ())); | ||
| 7084 | #endif | ||
| 7085 | |||
| 7070 | emacs_sigaction_init (&action, deliver_child_signal); | 7086 | emacs_sigaction_init (&action, deliver_child_signal); |
| 7071 | sigaction (SIGCHLD, &action, &old_action); | 7087 | sigaction (SIGCHLD, &action, &old_action); |
| 7072 | eassert (! (old_action.sa_flags & SA_SIGINFO)); | 7088 | eassert (! (old_action.sa_flags & SA_SIGINFO)); |
| @@ -7086,19 +7102,6 @@ init_process_emacs (void) | |||
| 7086 | 7102 | ||
| 7087 | inhibit_sentinels = 0; | 7103 | inhibit_sentinels = 0; |
| 7088 | 7104 | ||
| 7089 | #ifndef CANNOT_DUMP | ||
| 7090 | if (! noninteractive || initialized) | ||
| 7091 | #endif | ||
| 7092 | { | ||
| 7093 | #if defined HAVE_GLIB && !defined WINDOWSNT | ||
| 7094 | /* Tickle glib's child-handling code. Ask glib to wait for Emacs itself; | ||
| 7095 | this should always fail, but is enough to initialize glib's | ||
| 7096 | private SIGCHLD handler. */ | ||
| 7097 | g_source_unref (g_child_watch_source_new (getpid ())); | ||
| 7098 | #endif | ||
| 7099 | catch_child_signal (); | ||
| 7100 | } | ||
| 7101 | |||
| 7102 | FD_ZERO (&input_wait_mask); | 7105 | FD_ZERO (&input_wait_mask); |
| 7103 | FD_ZERO (&non_keyboard_wait_mask); | 7106 | FD_ZERO (&non_keyboard_wait_mask); |
| 7104 | FD_ZERO (&non_process_wait_mask); | 7107 | FD_ZERO (&non_process_wait_mask); |
diff --git a/src/process.h b/src/process.h index 0c4e17e68cf..9455df18beb 100644 --- a/src/process.h +++ b/src/process.h | |||
| @@ -217,8 +217,6 @@ extern void add_read_fd (int fd, fd_callback func, void *data); | |||
| 217 | extern void delete_read_fd (int fd); | 217 | extern void delete_read_fd (int fd); |
| 218 | extern void add_write_fd (int fd, fd_callback func, void *data); | 218 | extern void add_write_fd (int fd, fd_callback func, void *data); |
| 219 | extern void delete_write_fd (int fd); | 219 | extern void delete_write_fd (int fd); |
| 220 | #ifdef NS_IMPL_GNUSTEP | ||
| 221 | extern void catch_child_signal (void); | 220 | extern void catch_child_signal (void); |
| 222 | #endif | ||
| 223 | 221 | ||
| 224 | INLINE_HEADER_END | 222 | INLINE_HEADER_END |
diff --git a/src/sysdep.c b/src/sysdep.c index 1d3e646d359..c2769865b5d 100644 --- a/src/sysdep.c +++ b/src/sysdep.c | |||
| @@ -1901,6 +1901,8 @@ init_signals (bool dumping) | |||
| 1901 | sigaction (SIGFPE, &action, 0); | 1901 | sigaction (SIGFPE, &action, 0); |
| 1902 | } | 1902 | } |
| 1903 | 1903 | ||
| 1904 | catch_child_signal (); | ||
| 1905 | |||
| 1904 | #ifdef SIGUSR1 | 1906 | #ifdef SIGUSR1 |
| 1905 | add_user_signal (SIGUSR1, "sigusr1"); | 1907 | add_user_signal (SIGUSR1, "sigusr1"); |
| 1906 | #endif | 1908 | #endif |