[lkml]   [2000]   [Mar]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    SubjectRe: Is PTRACE_ATTACH lazy?
    Victor Zandy <> writes:
    > For example, I find that if I make two calls like this
    > ret = ptrace(PTRACE_ATTACH, pid, 0, 0);
    > ret = ptrace(PTRACE_DETACH, pid, 0, 0);
    > the second call will fail, with ESRCH.
    > My guess is that the traced process has not had its state set to
    > TASK_STOPPED before the second call to ptrace is executed. (Does the
    > traced process need to be scheduled before it will change to
    > Does anyone know for sure why this happens?

    Your guess is about right. A SIGSTOP is sent during the PTRACE_ATTACH

    send_sig(SIGSTOP, child, 1);

    and will complete (shortly) thereafter.

    > Can anyone suggest a workaround that to allow me make one or
    > more ptrace calls immediately after a PTRACE_ATTACH?

    The parent has to do a wait4 to wait for the child to stop. (You could also
    observe the stop by watching /proc/n/status, etc, but this isn't really


    Any sufficiently adverse technology is indistinguishable from Microsoft.

    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to
    Please read the FAQ at

     \ /
      Last update: 2005-03-22 13:56    [W:0.020 / U:15.560 seconds]
    ©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site