From 9eb686150237f54e5a41b8c7817593cd3edb942e Mon Sep 17 00:00:00 2001 From: normal Date: Sat, 30 Jun 2018 06:11:33 +0000 Subject: [PATCH] process.c: attempt to reap spawnvp (win32) result from mjit Basically in win32, mjit.c seems to work directly on spawnvp result while normal Ruby code wraps process handles to look like *nix PIDs. I'm only guessing, here... git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63797 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- process.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/process.c b/process.c index ef0523165e..cf8cc3ac96 100644 --- a/process.c +++ b/process.c @@ -923,15 +923,27 @@ waitpid_notify(struct waitpid_state *w, rb_pid_t ret) rb_native_cond_signal(w->cond); } -/* called by both timer thread and main thread */ +#ifdef _WIN32 /* for spawnvp result from mjit.c */ +# define waitpid_sys(pid,status,options) \ + (WaitForSingleObject((HANDLE)(pid), 0),\ + GetExitCodeProcess((HANDLE)(pid), (LPDWORD)(status))) +#else +# define waitpid_sys(pid,status,options) do_waitpid((pid),(status),(options)) +#endif +/* called by timer thread */ static void waitpid_each(struct list_head *head) { struct waitpid_state *w = 0, *next; list_for_each_safe(head, w, next, wnode) { - rb_pid_t ret = do_waitpid(w->pid, &w->status, w->options | WNOHANG); + rb_pid_t ret; + + if (w->ec) + ret = do_waitpid(w->pid, &w->status, w->options | WNOHANG); + else + ret = waitpid_sys(w->pid, &w->status, w->options | WNOHANG); if (!ret) continue; if (ret == -1) w->errnum = errno;