utrace: Start the tracee only after uloop initialization
authorMichal Sojka <sojkam1@fel.cvut.cz>
Wed, 27 Sep 2017 08:59:54 +0000 (10:59 +0200)
committerJohn Crispin <john@phrozen.org>
Thu, 28 Sep 2017 06:26:56 +0000 (08:26 +0200)
Without this, early ptrace stops can be missed because they can happen
before the call to uloop_init().

Signed-off-by: Michal Sojka <sojkam1@fel.cvut.cz>
trace/trace.c

index d0220791eab0ff6293d99dcbb12f20c2a8a6026a..76b6b7f260de41e2471c1ddaa6954d5db7291dee 100644 (file)
@@ -342,6 +342,9 @@ int main(int argc, char **argv, char **envp)
                return -1;
        }
 
+       /* Initialize uloop to catch all ptrace stops from now on. */
+       uloop_init();
+
        int ptrace_options = PTRACE_O_TRACEFORK | PTRACE_O_TRACEVFORK | PTRACE_O_TRACECLONE;
        switch (mode) {
        case UTRACE:
@@ -362,7 +365,6 @@ int main(int argc, char **argv, char **envp)
                return -1;
        }
 
-       uloop_init();
        tracer.proc.pid = child;
        tracer.proc.cb = tracer_cb;
        uloop_process_add(&tracer.proc);