ruby-changes:23961
From: akr <ko1@a...>
Date: Sun, 10 Jun 2012 15:51:14 +0900 (JST)
Subject: [ruby-changes:23961] akr:r36012 (trunk): * process.c (retry_fork): call after_fork except in a child process.
akr 2012-06-10 15:51:05 +0900 (Sun, 10 Jun 2012) New Revision: 36012 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=36012 Log: * process.c (retry_fork): call after_fork except in a child process. (rb_fork_internal): restrict after_fork call condition. Modified files: trunk/ChangeLog trunk/process.c Index: ChangeLog =================================================================== --- ChangeLog (revision 36011) +++ ChangeLog (revision 36012) @@ -1,3 +1,8 @@ +Sun Jun 10 15:49:47 2012 Tanaka Akira <akr@f...> + + * process.c (retry_fork): call after_fork except in a child process. + (rb_fork_internal): restrict after_fork call condition. + Sun Jun 10 14:19:33 2012 NARUSE, Yui <naruse@r...> * configure.in: NetBSD 6 adds libexecinfo but it only works on amd64. Index: process.c =================================================================== --- process.c (revision 36011) +++ process.c (revision 36012) @@ -2805,10 +2805,13 @@ if (!chfunc_is_async_signal_safe) before_fork(); pid = fork(); - if (0 <= pid) - break; + if (pid == 0) /* fork succeed, child process */ + return pid; if (!chfunc_is_async_signal_safe) - after_fork(); + preserving_errno(after_fork()); + if (0 < pid) /* fork succeed, parent process */ + return pid; + /* fork failed */ switch (errno) { case EAGAIN: #if defined(EWOULDBLOCK) && EWOULDBLOCK != EAGAIN @@ -2832,7 +2835,6 @@ return -1; } } - return pid; } static void @@ -2913,9 +2915,10 @@ pid = retry_fork(status, NULL, FALSE); if (pid < 0) return pid; - if (!pid) + if (!pid) { forked_child = 1; - after_fork(); + after_fork(); + } return pid; } else { @@ -2949,8 +2952,6 @@ _exit(127); #endif } - if (!chfunc_is_async_signal_safe) - after_fork(); close(ep[1]); error_occured = recv_child_error(ep[0], &state, &exc, &err, errmsg, errmsg_buflen, chfunc_is_async_signal_safe); if (state || error_occured) { -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/