[ERROR] 2.3.99-pre6 : waitpid() fails when running under debugger

From: Andris Pavenis (pavenis@latnet.lv)
Date: Thu May 11 2000 - 04:51:26 EST


Hi!

Test example included below works Ok under kernel-2.3.99-pre6 when run from
command line, but fails when running under debugger or strace (I'm getting
errno=ECHILD from waitpid() waiting for forked child process). There were
no such problem in 2.2.15 and earlier 2.2 kernels.

System: Pentium MMX200, glibc-2.1.3. I got this problem with kernel 2.3.99pre6
        compiled both with gcc-2.95.2 and gcc-2.7.2.3 so gcc version doesn't
        matter.

Andris

----------------- example -----------------------
#include <assert.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>

int main (void)
{
   int ret, status;
   pid_t pid;
   
   pid = fork ();
   assert (pid!=-1);
   if (pid==0)
     {
         fprintf (stderr,"\n### Child starting (pid=%d)\n",getpid());
         sleep (10);
         fprintf (stderr,"\n### Child ending\n");
         _exit (0);
     }
   ret=waitpid(pid, &status,0);
   fprintf (stderr,"\n### child pid %d status=%08X ret=%d\n",pid,status,ret);
   if (ret<0) perror ("\n ### waitpid");
   return 0;
}
---------------- output when run directly: ./example ----------

### Child starting (pid=30567)

### Child ending

### child pid 30567 status=00000000 ret=30567

---------------- output when run through strace: strace ./example --------
execve("./test2", ["test2"], [/* 34 vars */]) = 0
brk(0) = 0x8049890
open("/etc/ld.so.preload", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY) = 3
fstat(3, {...}) = 0
mmap() = 0x40014000
close(3) = 0
open("/lib/libc.so.6", O_RDONLY) = 3
fstat(3, {...}) = 0
read(3, 0xbfffe37c, 4096) = 4096
mmap() = 0x4001a000
mprotect(0x400f1000, 32380, PROT_NONE) = 0
mmap() = 0x400f1000
mmap() = 0x400f6000
close(3) = 0
munmap(0x40014000, 21610) = 0
personality(PER_LINUX) = 0
getpid() = 30549
fork() = 30550

### Child starting (pid=30550)
wait4(30550, 0xbffff934, 0, NULL) = -1 ECHILD (No child processes)
write(2, 0xbfffd2ec, 46
### child pid 30550 status=4000A080 ret=-1
) = 46
write(2, 0xbfffceac, 34
 ### waitpid: No child processes
) = 34
_exit(0) = ?

### Child ending
------------------------------------------------------------

-
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/



This archive was generated by hypermail 2b29 : Mon May 15 2000 - 21:00:17 EST