* 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:
akr 2012-06-10 06:51:05 +00:00
Родитель d9f3198dd9
Коммит 8fdd48d69f
2 изменённых файлов: 14 добавлений и 8 удалений

Просмотреть файл

@ -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>
* configure.in: NetBSD 6 adds libexecinfo but it only works on amd64.

Просмотреть файл

@ -2805,10 +2805,13 @@ retry_fork(int *status, int *ep, int chfunc_is_async_signal_safe)
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 @@ retry_fork(int *status, int *ep, int chfunc_is_async_signal_safe)
return -1;
}
}
return pid;
}
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);
if (pid < 0)
return pid;
if (!pid)
if (!pid) {
forked_child = 1;
after_fork();
after_fork();
}
return pid;
}
else {
@ -2949,8 +2952,6 @@ rb_fork_internal(int *status, int (*chfunc)(void*, char *, size_t), void *charg,
_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) {