summaryrefslogtreecommitdiff
path: root/process.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-09-05 16:36:35 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-09-05 16:36:35 +0000
commit31468275212035ab544997964bd95a7dc48a981d (patch)
tree1e909bcb01f6b6b6a7f162abb27bc963f1f7a21c /process.c
parent2942657a566e8e5cd3b037ffe9cb961252be9fd5 (diff)
* 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
Diffstat (limited to 'process.c')
-rw-r--r--process.c34
1 files changed, 21 insertions, 13 deletions
diff --git a/process.c b/process.c
index bc2a86d..0251dfd 100644
--- a/process.c
+++ b/process.c
@@ -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. */
- }
- if (ret == -1) {
- ERRMSG("sigaction to obtain old action");
- return -1;
+ 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 ((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");