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

ruby-changes:35276

From: akr <ko1@a...>
Date: Wed, 3 Sep 2014 00:13:52 +0900 (JST)
Subject: [ruby-changes:35276] akr:r47358 (trunk): * process.c (retry_fork_async_signal_safe): Don't return on in child

akr	2014-09-03 00:13:36 +0900 (Wed, 03 Sep 2014)

  New Revision: 47358

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

  Log:
    * process.c (retry_fork_async_signal_safe): Don't return on in child
      process.

  Modified files:
    trunk/ChangeLog
    trunk/process.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 47357)
+++ ChangeLog	(revision 47358)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Wed Sep  3 00:12:44 2014  Tanaka Akira  <akr@f...>
+
+	* process.c (retry_fork_async_signal_safe): Don't return on in child
+	  process.
+
 Tue Sep  2 23:47:35 2014  Tanaka Akira  <akr@f...>
 
 	* process.c (retry_fork_async_signal_safe): Specialized version of
Index: process.c
===================================================================
--- process.c	(revision 47357)
+++ process.c	(revision 47358)
@@ -3281,7 +3281,9 @@ recv_child_error(int fd, int *errp, char https://github.com/ruby/ruby/blob/trunk/process.c#L3281
 }
 
 static rb_pid_t
-retry_fork_async_signal_safe(int *status, int *ep)
+retry_fork_async_signal_safe(int *status, int *ep,
+        int (*chfunc)(void*, char *, size_t), void *charg,
+        char *errmsg, size_t errmsg_buflen)
 {
     rb_pid_t pid;
     int state = 0;
@@ -3290,8 +3292,19 @@ retry_fork_async_signal_safe(int *status https://github.com/ruby/ruby/blob/trunk/process.c#L3292
     while (1) {
         prefork();
         pid = fork();
-        if (pid == 0) /* fork succeed, child process */
-            return pid;
+        if (pid == 0) {/* fork succeed, child process */
+            int ret;
+            forked_child = 1;
+            close(ep[0]);
+            ret = chfunc(charg, errmsg, errmsg_buflen);
+            if (!ret) _exit(EXIT_SUCCESS);
+            send_child_error(ep[1], errmsg, errmsg_buflen);
+#if EXIT_SUCCESS == 127
+            _exit(EXIT_FAILURE);
+#else
+            _exit(127);
+#endif
+        }
         if (0 < pid) /* fork succeed, parent process */
             return pid;
         /* fork failed */
@@ -3313,22 +3326,9 @@ rb_fork_async_signal_safe(int *status, i https://github.com/ruby/ruby/blob/trunk/process.c#L3326
     if (status) *status = 0;
 
     if (pipe_nocrash(ep, fds)) return -1;
-    pid = retry_fork_async_signal_safe(status, ep);
+    pid = retry_fork_async_signal_safe(status, ep, chfunc, charg, errmsg, errmsg_buflen);
     if (pid < 0)
         return pid;
-    if (!pid) {
-        int ret;
-        forked_child = 1;
-        close(ep[0]);
-        ret = chfunc(charg, errmsg, errmsg_buflen);
-        if (!ret) _exit(EXIT_SUCCESS);
-        send_child_error(ep[1], errmsg, errmsg_buflen);
-#if EXIT_SUCCESS == 127
-        _exit(EXIT_FAILURE);
-#else
-        _exit(127);
-#endif
-    }
     close(ep[1]);
     error_occurred = recv_child_error(ep[0], &err, errmsg, errmsg_buflen);
     if (state || error_occurred) {

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

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