Skip to content

Commit

Permalink
Issue SimonKagstrom#163: ptrace: Ensure threads are stopped after att…
Browse files Browse the repository at this point in the history
…aching in start()
  • Loading branch information
SimonKagstrom committed Nov 25, 2016
1 parent 7f770ef commit 44b2b44
Showing 1 changed file with 2 additions and 15 deletions.
17 changes: 2 additions & 15 deletions src/engines/ptrace.cc
Original file line number Diff line number Diff line change
Expand Up @@ -592,9 +592,6 @@ class Ptrace : public IEngine
}
tie_process_to_cpu(m_activeChild, m_parentCpu);

::kill(m_activeChild, SIGSTOP);
ptrace(PTRACE_SETOPTIONS, m_activeChild, 0, PTRACE_O_TRACECLONE | PTRACE_O_TRACEFORK);

return true;
}

Expand Down Expand Up @@ -687,13 +684,8 @@ class Ptrace : public IEngine
return errno;
ptrace(PTRACE_SETOPTIONS, lwpid, 0, PTRACE_O_TRACECLONE | PTRACE_O_TRACEFORK | PTRACE_O_TRACEVFORK);

if (linux_proc_pid_is_stopped (lwpid)) {
/* The process is definitely stopped. It is in a job control
* stop, unless the kernel predates the TASK_STOPPED /
* TASK_TRACED distinction, in which case it might be in a
* ptrace stop. Make sure it is in a ptrace stop; from there we
* can kill it, signal it, et cetera.
*
if (!linux_proc_pid_is_stopped (lwpid)) {
/*
* First make sure there is a pending SIGSTOP. Since we are
* already attached, the process can not transition from stopped
* to running without a PTRACE_CONT; so we know this signal will
Expand All @@ -702,11 +694,6 @@ class Ptrace : public IEngine
* enough to use TASK_STOPPED for ptrace stops); but since
* SIGSTOP is not an RT signal, it can only be queued once. */
kill_lwp (lwpid, SIGSTOP);

/* Finally, resume the stopped process. This will deliver the
* SIGSTOP (or a higher priority signal, just like normal
* PTRACE_ATTACH), which we'll catch later on. */
ptrace (PTRACE_CONT, lwpid, 0, 0);
}

return 0;
Expand Down

0 comments on commit 44b2b44

Please sign in to comment.