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

ruby-changes:19717

From: kosaki <ko1@a...>
Date: Sun, 29 May 2011 00:24:27 +0900 (JST)
Subject: [ruby-changes:19717] kosaki:r31762 (trunk): * process.c (before_exec, after_exec): change from macro to function.

kosaki	2011-05-29 00:24:18 +0900 (Sun, 29 May 2011)

  New Revision: 31762

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

  Log:
    * process.c (before_exec, after_exec): change from macro to function.

  Modified files:
    trunk/ChangeLog
    trunk/process.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 31761)
+++ ChangeLog	(revision 31762)
@@ -1,3 +1,7 @@
+Sun May 29 00:22:40 2011  KOSAKI Motohiro  <kosaki.motohiro@g...>
+
+	* process.c (before_exec, after_exec): change from macro to function.
+
 Sat May 28 19:30:17 2011  KOSAKI Motohiro  <kosaki.motohiro@g...>
 
 	* process.c (before_exec, after_exec): change SIGPIPE handler to SIG_DFL
Index: process.c
===================================================================
--- process.c	(revision 31761)
+++ process.c	(revision 31762)
@@ -992,33 +992,47 @@
 # define signal(a,b) posix_signal((a),(b))
 #endif
 
-static void save_sigpipe(void)
+static void before_exec(void)
 {
+    /*
+     * signalmask is inherited across exec() and almost system commands don't
+     * work if signalmask is blocked.
+     */
+    rb_enable_interrupt();
+
 #ifdef SIGPIPE
     /*
-     * Some OS commands don't initialize signal handler properly. Thus we have to
-     * reset signal handler before exec(). Otherwise, system() and similar child process
-     * interaction might fail. (e.g. ruby -e "system 'yes | ls'") [ruby-dev:12261]
+     * Some OS commands don't initialize signal handler properly. Thus we have
+     * to reset signal handler before exec(). Otherwise, system() and similar
+     * child process interaction might fail. (e.g. ruby -e "system 'yes | ls'")
+     * [ruby-dev:12261]
      */
     saved_sigpipe_handler = signal(SIGPIPE, SIG_DFL);
 #endif
+
+    if (!forked_child) {
+	/*
+	 * On old MacOS X, exec() may return ENOTSUPP if the process have
+	 * multiple threads. Therefore we have to kill internal threads at once.
+	 * [ruby-core: 10583]
+	 */
+	rb_thread_stop_timer_thread();
+    }
 }
 
-static void restore_sigpipe(void)
+static void after_exec(void)
 {
+    rb_thread_reset_timer_thread();
+    rb_thread_start_timer_thread();
+
 #ifdef SIGPIPE
     signal(SIGPIPE, saved_sigpipe_handler);
 #endif
+
+    forked_child = 0;
+    rb_disable_interrupt();
 }
 
-/*
- * On old MacOS X, exec() may return ENOTSUPP if the process have multiple threads.
- * Therefore we have to kill internal threads at once. [ruby-core: 10583]
- */
-#define before_exec() \
-    (rb_enable_interrupt(), save_sigpipe(), (void)(forked_child ? 0 : (rb_thread_stop_timer_thread(), 1)))
-#define after_exec() \
-    (rb_thread_reset_timer_thread(), rb_thread_start_timer_thread(), forked_child = 0, restore_sigpipe(), rb_disable_interrupt())
 #define before_fork() before_exec()
 #define after_fork() (GET_THREAD()->thrown_errinfo = 0, after_exec())
 

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

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