зеркало из https://github.com/github/ruby.git
* process.c (retry_fork_async_signal_safe): Don't return on in child
process. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47358 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
93621161d6
Коммит
34af76e318
|
@ -1,3 +1,8 @@
|
|||
Wed Sep 3 00:12:44 2014 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* process.c (retry_fork_async_signal_safe): Don't return on in child
|
||||
process.
|
||||
|
||||
Tue Sep 2 23:47:35 2014 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* process.c (retry_fork_async_signal_safe): Specialized version of
|
||||
|
|
34
process.c
34
process.c
|
@ -3281,7 +3281,9 @@ recv_child_error(int fd, int *errp, char *errmsg, size_t errmsg_buflen)
|
|||
}
|
||||
|
||||
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, int *ep)
|
|||
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, int (*chfunc)(void*, char *, size_t), voi
|
|||
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) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче