[前][次][番号順一覧][スレッド一覧]

ruby-changes:35339

From: akr <ko1@a...>
Date: Sat, 6 Sep 2014 01:36:48 +0900 (JST)
Subject: [ruby-changes:35339] akr:r47421 (trunk): * process.c (rb_f_exec): Call before_exec_async_signal_safe and

akr	2014-09-06 01:36:35 +0900 (Sat, 06 Sep 2014)

  New Revision: 47421

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=47421

  Log:
    * 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.

  Modified files:
    trunk/ChangeLog
    trunk/process.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 47420)
+++ ChangeLog	(revision 47421)
@@ -1,3 +1,13 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sat Sep  6 01:34:31 2014  Tanaka Akira  <akr@f...>
+
+	* 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@f...>
 
 	* signal.c (ruby_signal): Don't set SA_SIGINFO for SIG_IGN and
Index: process.c
===================================================================
--- process.c	(revision 47420)
+++ process.c	(revision 47421)
@@ -2450,7 +2450,9 @@ rb_f_exec(int argc, const VALUE *argv) https://github.com/ruby/ruby/blob/trunk/process.c#L2450
 #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 r https://github.com/ruby/ruby/blob/trunk/process.c#L3057
     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 r https://github.com/ruby/ruby/blob/trunk/process.c#L3075
 #endif
 
 failure:
-    preserving_errno(after_exec_async_signal_safe()); /* async-signal-safe */
     return -1;
 }
 
@@ -3084,9 +3083,9 @@ static int https://github.com/ruby/ruby/blob/trunk/process.c#L3083
 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_ https://github.com/ruby/ruby/blob/trunk/process.c#L3425
     }
 
     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");

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]