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

ruby-changes:23948

From: akr <ko1@a...>
Date: Sun, 10 Jun 2012 06:49:14 +0900 (JST)
Subject: [ruby-changes:23948] akr:r35999 (trunk): * process.c: split after_exec into async-signal-safe part and rest.

akr	2012-06-10 06:48:42 +0900 (Sun, 10 Jun 2012)

  New Revision: 35999

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

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

  Modified files:
    trunk/ChangeLog
    trunk/process.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 35998)
+++ ChangeLog	(revision 35999)
@@ -1,3 +1,13 @@
+Sun Jun 10 06:43:51 2012  Tanaka Akira  <akr@f...>
+
+	* 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@g...>
 
 	* NEWS: document new features of Ruby OpenSSL.
Index: process.c
===================================================================
--- process.c	(revision 35998)
+++ process.c	(revision 35999)
@@ -1026,18 +1026,28 @@
     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)
 {
+#ifdef SIGPIPE
+    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();
 
-#ifdef SIGPIPE
-    signal(SIGPIPE, saved_sigpipe_handler);
-#endif
-
     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 @@
     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 @@
 #else
 # undef sargp
 #endif
+
+failure:
+    preserving_errno(after_exec_async_signal_safe()); /* async-signal-safe */
     return -1;
 }
 
@@ -2632,7 +2645,7 @@
     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;
 }
 

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

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