aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPetr Machata <pmachata@redhat.com>2011-11-22 16:50:36 +0100
committerPetr Machata <pmachata@redhat.com>2011-11-22 16:50:36 +0100
commit97b208405bcbf2fc75a70fba7d094740f590cb90 (patch)
tree51c97eacc0a482ac3783c5471fc77a56669d8fa0
parent12387c439d08755c0d8edf2516677d3f7b1f6ef0 (diff)
downloadltrace-97b208405bcbf2fc75a70fba7d094740f590cb90.tar.gz
Turn in a workaround for seeing a process as R after waitpid (should be T)
-rw-r--r--sysdeps/linux-gnu/events.c21
1 files changed, 21 insertions, 0 deletions
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 <string.h>
#include <sys/ptrace.h>
#include <assert.h>
+#include <unistd.h>
#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);