* process.c (retry_fork): call after_fork except in a child process.
(rb_fork_internal): restrict after_fork call condition. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36012 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
d9f3198dd9
commit
8fdd48d69f
@ -1,3 +1,8 @@
|
|||||||
|
Sun Jun 10 15:49:47 2012 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
|
* 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@ruby-lang.org>
|
Sun Jun 10 14:19:33 2012 NARUSE, Yui <naruse@ruby-lang.org>
|
||||||
|
|
||||||
* configure.in: NetBSD 6 adds libexecinfo but it only works on amd64.
|
* configure.in: NetBSD 6 adds libexecinfo but it only works on amd64.
|
||||||
|
15
process.c
15
process.c
@ -2805,10 +2805,13 @@ retry_fork(int *status, int *ep, int chfunc_is_async_signal_safe)
|
|||||||
if (!chfunc_is_async_signal_safe)
|
if (!chfunc_is_async_signal_safe)
|
||||||
before_fork();
|
before_fork();
|
||||||
pid = fork();
|
pid = fork();
|
||||||
if (0 <= pid)
|
if (pid == 0) /* fork succeed, child process */
|
||||||
break;
|
return pid;
|
||||||
if (!chfunc_is_async_signal_safe)
|
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) {
|
switch (errno) {
|
||||||
case EAGAIN:
|
case EAGAIN:
|
||||||
#if defined(EWOULDBLOCK) && EWOULDBLOCK != EAGAIN
|
#if defined(EWOULDBLOCK) && EWOULDBLOCK != EAGAIN
|
||||||
@ -2832,7 +2835,6 @@ retry_fork(int *status, int *ep, int chfunc_is_async_signal_safe)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return pid;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -2913,9 +2915,10 @@ rb_fork_internal(int *status, int (*chfunc)(void*, char *, size_t), void *charg,
|
|||||||
pid = retry_fork(status, NULL, FALSE);
|
pid = retry_fork(status, NULL, FALSE);
|
||||||
if (pid < 0)
|
if (pid < 0)
|
||||||
return pid;
|
return pid;
|
||||||
if (!pid)
|
if (!pid) {
|
||||||
forked_child = 1;
|
forked_child = 1;
|
||||||
after_fork();
|
after_fork();
|
||||||
|
}
|
||||||
return pid;
|
return pid;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -2949,8 +2952,6 @@ rb_fork_internal(int *status, int (*chfunc)(void*, char *, size_t), void *charg,
|
|||||||
_exit(127);
|
_exit(127);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
if (!chfunc_is_async_signal_safe)
|
|
||||||
after_fork();
|
|
||||||
close(ep[1]);
|
close(ep[1]);
|
||||||
error_occured = recv_child_error(ep[0], &state, &exc, &err, errmsg, errmsg_buflen, chfunc_is_async_signal_safe);
|
error_occured = recv_child_error(ep[0], &state, &exc, &err, errmsg, errmsg_buflen, chfunc_is_async_signal_safe);
|
||||||
if (state || error_occured) {
|
if (state || error_occured) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user