* process.c (rb_f_exec): Call before_exec_async_signal_safe and

after_exec_async_signal_safe around rb_exec_async_signal_safe.
  (rb_exec_async_signal_safe): Don't call
  before_exec_async_signal_safe and after_exec_async_signal_safe.
  (rb_exec_without_timer_thread): Call before_exec and
  after_exec.
  (disable_child_handler_fork_child): Make SIGPIPE handler SIG_DFL.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47421 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2014-09-05 16:36:35 +00:00
Родитель 2942657a56
Коммит 3146827521
2 изменённых файлов: 31 добавлений и 13 удалений

Просмотреть файл

@ -1,3 +1,13 @@
Sat Sep 6 01:34:31 2014 Tanaka Akira <akr@fsij.org>
* process.c (rb_f_exec): Call before_exec_async_signal_safe and
after_exec_async_signal_safe around rb_exec_async_signal_safe.
(rb_exec_async_signal_safe): Don't call
before_exec_async_signal_safe and after_exec_async_signal_safe.
(rb_exec_without_timer_thread): Call before_exec and
after_exec.
(disable_child_handler_fork_child): Make SIGPIPE handler SIG_DFL.
Sat Sep 6 00:49:41 2014 Tanaka Akira <akr@fsij.org>
* signal.c (ruby_signal): Don't set SA_SIGINFO for SIG_IGN and

Просмотреть файл

@ -2450,7 +2450,9 @@ rb_f_exec(int argc, const VALUE *argv)
#if defined(__APPLE__) || defined(__HAIKU__)
rb_exec_without_timer_thread(eargp, errmsg, sizeof(errmsg));
#else
before_exec_async_signal_safe(); /* async-signal-safe */
rb_exec_async_signal_safe(eargp, errmsg, sizeof(errmsg));
preserving_errno(after_exec_async_signal_safe()); /* async-signal-safe */
#endif
RB_GC_GUARD(execarg_obj);
if (errmsg[0])
@ -3055,8 +3057,6 @@ rb_exec_async_signal_safe(const struct rb_execarg *eargp, char *errmsg, size_t e
struct rb_execarg *const sargp = NULL;
#endif
before_exec_async_signal_safe(); /* async-signal-safe */
if (rb_execarg_run_options(eargp, sargp, errmsg, errmsg_buflen) < 0) { /* hopefully async-signal-safe */
goto failure;
}
@ -3075,7 +3075,6 @@ rb_exec_async_signal_safe(const struct rb_execarg *eargp, char *errmsg, size_t e
#endif
failure:
preserving_errno(after_exec_async_signal_safe()); /* async-signal-safe */
return -1;
}
@ -3084,9 +3083,9 @@ static int
rb_exec_without_timer_thread(const struct rb_execarg *eargp, char *errmsg, size_t errmsg_buflen)
{
int ret;
before_exec_non_async_signal_safe(); /* not async-signal-safe because it calls rb_thread_stop_timer_thread. */
before_exec()
ret = rb_exec_async_signal_safe(eargp, errmsg, errmsg_buflen); /* hopefully async-signal-safe */
preserving_errno(after_exec_non_async_signal_safe()); /* not async-signal-safe because it calls rb_thread_start_timer_thread. */
preserving_errno(after_exec()); /* not async-signal-safe because it calls rb_thread_start_timer_thread. */
return ret;
}
#endif
@ -3426,15 +3425,24 @@ disable_child_handler_fork_child(sigset_t *oldset, char *errmsg, size_t errmsg_b
}
for (sig = 1; sig < NSIG; sig++) {
ret = sigaction(sig, NULL, &oact); /* async-signal-safe */
if (ret == -1 && errno == EINVAL) {
continue; /* Ignore invalid signal number. */
int reset = 0;
#ifdef SIGPIPE
if (sig == SIGPIPE)
reset = 1;
#endif
if (!reset) {
ret = sigaction(sig, NULL, &oact); /* async-signal-safe */
if (ret == -1 && errno == EINVAL) {
continue; /* Ignore invalid signal number. */
}
if (ret == -1) {
ERRMSG("sigaction to obtain old action");
return -1;
}
reset = (oact.sa_flags & SA_SIGINFO) ||
(oact.sa_handler != SIG_IGN && oact.sa_handler != SIG_DFL);
}
if (ret == -1) {
ERRMSG("sigaction to obtain old action");
return -1;
}
if ((oact.sa_flags & SA_SIGINFO) || (oact.sa_handler != SIG_IGN && oact.sa_handler != SIG_DFL)) {
if (reset) {
ret = sigaction(sig, &act, NULL); /* async-signal-safe */
if (ret == -1) {
ERRMSG("sigaction to set default action");