lkml.org 
[lkml]   [2000]   [Mar]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectIs PTRACE_ATTACH lazy?

On x86 Linux 2.2.12 a valid ptrace call that closely follows a
successful PTRACE_ATTACH can fail, with error ESRCH.

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.

However, if I put some time between the calls, like this

ret = ptrace(PTRACE_ATTACH, pid, 0, 0);
usleep(100);
ret = ptrace(PTRACE_DETACH, pid, 0, 0);

then the second call will succeed.


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
TASK_STOPPED?)

Does anyone know for sure why this happens?

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

Thanks.

Vic Zandy

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:56    [W:0.186 / U:1.148 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site