From 97b208405bcbf2fc75a70fba7d094740f590cb90 Mon Sep 17 00:00:00 2001 From: Petr Machata Date: Tue, 22 Nov 2011 16:50:36 +0100 Subject: Turn in a workaround for seeing a process as R after waitpid (should be T) --- sysdeps/linux-gnu/events.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/sysdeps/linux-gnu/events.c b/sysdeps/linux-gnu/events.c index 0685342..021192f 100644 --- a/sysdeps/linux-gnu/events.c +++ b/sysdeps/linux-gnu/events.c @@ -9,6 +9,7 @@ #include #include #include +#include #include "common.h" @@ -138,6 +139,26 @@ next_event(void) } event.proc = pid2proc(pid); if (!event.proc || event.proc->state == STATE_BEING_CREATED) { + /* Work around (presumably) a bug on some kernels, + * where we are seeing a waitpid event even though the + * process is still reported to be running. Wait for + * the tracing stop to propagate. But don't get stuck + * here forever. + * + * We need the process in T, because there's a lot of + * ptracing going on all over the place, and these + * calls fail when the process is not in T. + * + * N.B. This was observed on RHEL 5 Itanium, but I'm + * turning this on globally, to save some poor soul + * down the road (which could well be me a year from + * now) the pain of figuring this out all over again. + * Petr Machata 2011-11-22. */ + int i = 0; + for (; i < 100 && process_status(pid) != ps_tracing_stop; ++i) { + debug(2, "waiting for %d to stop", pid); + usleep(10000); + } event.type = EVENT_NEW; event.e_un.newpid = pid; debug(DEBUG_EVENT, "event: NEW: pid=%d", pid); -- cgit v1.2.3