ruby-changes:39711
From: nobu <ko1@a...>
Date: Tue, 8 Sep 2015 16:00:24 +0900 (JST)
Subject: [ruby-changes:39711] nobu:r51792 (trunk): process.c: retry loop
nobu 2015-09-08 16:00:13 +0900 (Tue, 08 Sep 2015) New Revision: 51792 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=51792 Log: process.c: retry loop * process.c (rb_waitpid): refactor retry loop by interrupt. Modified files: trunk/process.c Index: process.c =================================================================== --- process.c (revision 51791) +++ process.c (revision 51792) @@ -863,25 +863,28 @@ rb_waitpid_blocking(void *data) https://github.com/ruby/ruby/blob/trunk/process.c#L863 return (void *)(VALUE)result; } -rb_pid_t -rb_waitpid(rb_pid_t pid, int *st, int flags) +static rb_pid_t +do_waitpid_nonblocking(rb_pid_t pid, int *st, int flags) { - rb_pid_t result; + void *result; struct waitpid_arg arg; - - retry: arg.pid = pid; arg.st = st; arg.flags = flags; - result = (rb_pid_t)(VALUE)rb_thread_call_without_gvl(rb_waitpid_blocking, &arg, - RUBY_UBF_PROCESS, 0); - if (result < 0) { - if (errno == EINTR) { - rb_thread_t *th = GET_THREAD(); - RUBY_VM_CHECK_INTS(th); - goto retry; - } - return (rb_pid_t)-1; + result = rb_thread_call_without_gvl(rb_waitpid_blocking, &arg, + RUBY_UBF_PROCESS, 0); + return (rb_pid_t)(VALUE)result; +} + +rb_pid_t +rb_waitpid(rb_pid_t pid, int *st, int flags) +{ + rb_pid_t result; + + while ((result = do_waitpid_nonblocking(pid, st, flags)) < 0 && + (errno == EINTR)) { + rb_thread_t *th = GET_THREAD(); + RUBY_VM_CHECK_INTS(th); } if (result > 0) { rb_last_status_set(*st, result); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/