summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-06-09 21:48:42 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-06-09 21:48:42 +0000
commit99c71b1ee4024bd9112e26cc442d9c91b2bc75e3 (patch)
treea26ef8f97e0821dc58294a11ef9b7870f3cd0992
parente6424f805bffc64655cc80ede8bd6f396c57e306 (diff)
* process.c: split after_exec into async-signal-safe part and rest.
(after_exec_async_signal_safe): extracted from after_exec. (after_exec_non_async_signal_safe): ditto. (after_exec): call them. (rb_exec_async_signal_safe): call after_exec_async_signal_safe. (rb_exec_err): call after_exec_non_async_signal_safe instead of after_exec. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35999 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog10
-rw-r--r--process.c27
2 files changed, 30 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index c9659c9cd77..c32aea97303 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+Sun Jun 10 06:43:51 2012 Tanaka Akira <akr@fsij.org>
+
+ * process.c: split after_exec into async-signal-safe part and rest.
+ (after_exec_async_signal_safe): extracted from after_exec.
+ (after_exec_non_async_signal_safe): ditto.
+ (after_exec): call them.
+ (rb_exec_async_signal_safe): call after_exec_async_signal_safe.
+ (rb_exec_err): call after_exec_non_async_signal_safe instead of
+ after_exec.
+
Sun Jun 10 06:21:10 2012 Martin Bosslet <Martin.Bosslet@googlemail.com>
* NEWS: document new features of Ruby OpenSSL.
diff --git a/process.c b/process.c
index f2be6c0f110..e452a9228be 100644
--- a/process.c
+++ b/process.c
@@ -1026,18 +1026,28 @@ static void before_exec(void)
before_exec_async_signal_safe();
}
-static void after_exec(void)
+/* This function should be async-signal-safe. Actually it is. */
+static void after_exec_async_signal_safe(void)
{
- rb_thread_reset_timer_thread();
- rb_thread_start_timer_thread();
-
#ifdef SIGPIPE
- signal(SIGPIPE, saved_sigpipe_handler);
+ signal(SIGPIPE, saved_sigpipe_handler); /* async-signal-safe */
#endif
+}
+
+static void after_exec_non_async_signal_safe(void)
+{
+ rb_thread_reset_timer_thread();
+ rb_thread_start_timer_thread();
forked_child = 0;
}
+static void after_exec(void)
+{
+ after_exec_async_signal_safe();
+ after_exec_non_async_signal_safe();
+}
+
#define before_fork() before_exec()
#define after_fork() (GET_THREAD()->thrown_errinfo = 0, after_exec())
@@ -2606,7 +2616,7 @@ rb_exec_async_signal_safe(const struct rb_exec_arg *e, char *errmsg, size_t errm
before_exec_async_signal_safe(); /* async-signal-safe */
if (rb_run_exec_options_err(e, sargp, errmsg, errmsg_buflen) < 0) { /* hopefully async-signal-safe */
- return -1;
+ goto failure;
}
if (e->use_shell) {
@@ -2623,6 +2633,9 @@ rb_exec_async_signal_safe(const struct rb_exec_arg *e, char *errmsg, size_t errm
#else
# undef sargp
#endif
+
+failure:
+ preserving_errno(after_exec_async_signal_safe()); /* async-signal-safe */
return -1;
}
@@ -2632,7 +2645,7 @@ rb_exec_err(const struct rb_exec_arg *e, char *errmsg, size_t errmsg_buflen)
int ret;
before_exec_non_async_signal_safe(); /* async-signal-safe if forked_child is true */
ret = rb_exec_async_signal_safe(e, errmsg, errmsg_buflen);
- preserving_errno(after_exec()); /* not async-signal-safe because after_exec calls rb_thread_start_timer_thread. */
+ preserving_errno(after_exec_non_async_signal_safe()); /* not async-signal-safe because after_exec calls rb_thread_start_timer_thread. */
return ret;
}