Hi,

you have a race in the testcase, attached patch removes the race and it no
longer fails for me afterwards on kernel-2.6.25-14.fc9.x86_64 .

The while-loop last command there is
  ptrace(PTRACE_SYSCALL, child, 0, 0);
and then you try to do
  ptrace(PTRACE_CONT, child, 0, SIGKILL);

You must do waitpid() in between as otherwise CHILD may still be running (and
not stopped).  It is a correct behavior ptrace(2) returns ESRCH if CHILD is
still not stopped.

If you do
  ptrace(PTRACE_KILL, child, 0,0);
there is no race as this command works in any state of CHILD - either already
stopped or still running.


Anyway thanks for testing ptrace/utrace,
Jan
--- ptrace-syscall-ret.c-orig   2008-05-15 18:44:29.000000000 +0200
+++ ptrace-syscall-ret.c        2008-05-15 18:46:18.000000000 +0200
@@ -67,20 +67,18 @@ int main(int argc, char **argv) {
         assert(WIFSTOPPED(status));
         assert(WSTOPSIG(status) == SIGSTOP);
 
-       l = ptrace(PTRACE_SYSCALL,child, 0, 0);
-       assert(l==0);
-
                j = 0;
        while (j < LOOP){
 
+                     l = ptrace(PTRACE_SYSCALL, child, 0, 0);
+             assert(l==0);
+
              pid = waitpid(child, &status, 0);
              assert(child==pid);
                
              assert(WIFSTOPPED(status));
              assert(WSTOPSIG(status) == SIGTRAP);
 
-                     l = ptrace(PTRACE_SYSCALL, child, 0, 0);
-             assert(l==0);
              j++;
          } //end loop
 

Reply via email to