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

ruby-changes:23938

From: akr <ko1@a...>
Date: Sat, 9 Jun 2012 23:45:55 +0900 (JST)
Subject: [ruby-changes:23938] akr:r35989 (trunk): * process.c (before_exec_async_signal_safe): extracted from

akr	2012-06-09 23:45:46 +0900 (Sat, 09 Jun 2012)

  New Revision: 35989

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

  Log:
    * process.c (before_exec_async_signal_safe): extracted from
      before_exec.
      (before_exec_non_async_signal_safe): ditto.
      (before_exec): call before_exec_async_signal_safe and
      before_exec_non_async_signal_safe.
      (rb_exec_async_signal_safe): call before_exec_async_signal_safe.
      (rb_exec_err): call before_exec_non_async_signal_safe instead of
      before_exec.

  Modified files:
    trunk/ChangeLog
    trunk/process.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 35988)
+++ ChangeLog	(revision 35989)
@@ -1,3 +1,14 @@
+Sat Jun  9 23:44:29 2012  Tanaka Akira  <akr@f...>
+
+	* process.c (before_exec_async_signal_safe): extracted from
+	  before_exec.
+	  (before_exec_non_async_signal_safe): ditto.
+	  (before_exec): call before_exec_async_signal_safe and
+	  before_exec_non_async_signal_safe.
+	  (rb_exec_async_signal_safe): call before_exec_async_signal_safe.
+	  (rb_exec_err): call before_exec_non_async_signal_safe instead of
+	  before_exec.
+
 Sat Jun  9 23:36:53 2012  Nobuyoshi Nakada  <nobu@r...>
 
 	* iseq.c (iseq_load, insn_operand_intern, rb_iseq_disasm)
Index: process.c
===================================================================
--- process.c	(revision 35988)
+++ process.c	(revision 35989)
@@ -994,7 +994,8 @@
 }
 #endif
 
-static void before_exec(void)
+/* This function should be async-signal-safe.  Actually it is. */
+static void before_exec_async_signal_safe(void)
 {
 #ifdef SIGPIPE
     /*
@@ -1003,9 +1004,12 @@
      * child process interaction might fail. (e.g. ruby -e "system 'yes | ls'")
      * [ruby-dev:12261]
      */
-    saved_sigpipe_handler = signal(SIGPIPE, sig_do_nothing);
+    saved_sigpipe_handler = signal(SIGPIPE, sig_do_nothing); /* async-signal-safe */
 #endif
+}
 
+static void before_exec_non_async_signal_safe(void)
+{
     if (!forked_child) {
 	/*
 	 * On Mac OS X 10.5.x (Leopard) or earlier, exec() may return ENOTSUPP
@@ -1016,6 +1020,12 @@
     }
 }
 
+static void before_exec(void)
+{
+    before_exec_non_async_signal_safe();
+    before_exec_async_signal_safe();
+}
+
 static void after_exec(void)
 {
     rb_thread_reset_timer_thread();
@@ -2593,6 +2603,8 @@
 # define sargp NULL
 #endif
 
+    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;
     }
@@ -2618,7 +2630,7 @@
 rb_exec_err(const struct rb_exec_arg *e, char *errmsg, size_t errmsg_buflen)
 {
     int ret;
-    before_exec(); /* async-signal-safe if forked_child is true */
+    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.  */
     return ret;

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

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