From: Eric Wong <e@80x24.org>
To: spew@80x24.org
Cc: Eric Wong <e@80x24.org>
Subject: [PATCH 8/8] wip testing
Date: Mon, 25 Jun 2018 23:50:51 +0000 [thread overview]
Message-ID: <20180625235051.66045-9-e@80x24.org> (raw)
In-Reply-To: <20180625235051.66045-1-e@80x24.org>
---
mjit.c | 5 +++--
process.c | 12 +++++++++---
2 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/mjit.c b/mjit.c
index a550d1aabd..2e11395851 100644
--- a/mjit.c
+++ b/mjit.c
@@ -421,8 +421,9 @@ exec_process(const char *path, char *const argv[])
pid_t r = vm ? ruby_waitpid_locked(vm, pid, &stat, 0, &cond)
: waitpid(pid, &stat, 0);
if (r == -1) {
- if (errno == EINTR) continue; /* should never happen */
- fprintf(stderr, "waitpid: %s\n", strerror(errno));
+ if (errno == EINTR) continue;
+ fprintf(stderr, "[%d] waitpid(%d): %s\n",
+ getpid(), pid, strerror(errno));
break;
}
else if (r == pid) {
diff --git a/process.c b/process.c
index 0b91b30075..ce1445fbaa 100644
--- a/process.c
+++ b/process.c
@@ -919,7 +919,6 @@ static void
waitpid_notify(struct waitpid_state *w, pid_t ret)
{
w->ret = ret;
- if (w->ret == -1) w->errnum = errno;
list_del_init(&w->wnode);
rb_native_cond_signal(w->cond);
}
@@ -933,7 +932,9 @@ ruby_waitpid_all(rb_vm_t *vm)
rb_native_mutex_lock(&vm->waitpid_lock);
list_for_each_safe(&vm->waiting_pids, w, next, wnode) {
pid_t ret = do_waitpid(w->pid, &w->status, w->options | WNOHANG);
+
if (!ret) continue;
+ if (ret == -1) w->errnum = errno;
if (w->ec) { /* rb_waitpid */
rb_thread_t *th = rb_ec_thread_ptr(w->ec);
@@ -985,7 +986,7 @@ ruby_waitpid_locked(rb_vm_t *vm, rb_pid_t pid, int *status, int options,
if (status) {
*status = w.status;
}
- errno = w.errnum;
+ if (w.ret == -1) errno = w.errnum;
return w.ret;
}
@@ -1061,7 +1062,11 @@ waitpid_wait(struct waitpid_state *w)
}
else {
w->cond = rb_sleep_cond_get(w->ec);
- list_add(&vm->waiting_pids, &w->wnode);
+ /* order matters, favor specified PIDs rather than -1 or 0 */
+ if (w->pid > 0)
+ list_add(&vm->waiting_pids, &w->wnode);
+ else
+ list_add_tail(&vm->waiting_pids, &w->wnode);
}
rb_native_mutex_unlock(&vm->waitpid_lock);
@@ -1086,6 +1091,7 @@ rb_waitpid(rb_pid_t pid, int *st, int flags)
if (result > 0) {
rb_last_status_set(*st, result);
}
+ if (w.ret == -1) errno = w.errnum;
return result;
}
--
EW
prev parent reply other threads:[~2018-06-25 23:51 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-25 23:50 [PATCHv3 0/8] mjit SIGCHLD hijack series Eric Wong
2018-06-25 23:50 ` [PATCH 1/8] hijack SIGCHLD handler for internal use Eric Wong
2018-06-25 23:50 ` [PATCH 2/8] fix SIGCHLD hijacking race conditions Eric Wong
2018-06-25 23:50 ` [PATCH 3/8] mjit.c: allow working on platforms without SIGCHLD Eric Wong
2018-06-25 23:50 ` [PATCH 4/8] cleanups Eric Wong
2018-06-25 23:50 ` [PATCH 5/8] handle SIGCHLD in both the timer-thread and main thread Eric Wong
2018-06-25 23:50 ` [PATCH 6/8] Revert "test_process.rb: skip tests for Bug 14867" Eric Wong
2018-06-25 23:50 ` [PATCH 7/8] Revert "spec: skip Process wait specs on MJIT" Eric Wong
2018-06-25 23:50 ` Eric Wong [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180625235051.66045-9-e@80x24.org \
--to=e@80x24.org \
--cc=spew@80x24.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).