Subject: compat/linux32: getpid() returning wrong pid after clone()
To: None <>
From: =?ISO-8859-1?Q?Edgar_Fu=DF?= <>
List: port-amd64
Date: 03/15/2007 21:57:03
I'm confused.
(Syscall #158 actually is implemented in the kernel I'm using. I  
simply don't know how to tell kdump it is.)

   5183      1 dsmc     RET   clone 5247/0x147f
   5183      1 dsmc     CALL  kill(0x83b, SIGRT0)
   5183      1 dsmc     RET   kill 0
   2107      1 dsmc     RET   rt_sigsuspend -1 unknown errno 4
   2107      1 dsmc     PSIG  SIGRT0 caught handler=0xfbf663d0 mask= 
   2107      1 dsmc     CALL  sigreturn(0xffffcbdc)
   2107      1 dsmc     RET   sigreturn -1 errno -2 No such file or  
   2107      1 dsmc     CALL  #158 (unimplemented sched_yield)
   5247      1 dsmc     EMUL  "linux32"
   5247      1 dsmc     RET   fork 0
   5247      1 dsmc     CALL  getpid
   5247      1 dsmc     RET   getpid 2107/0x83b

I've been staring at this for minutes now, but probably others concur  
that getpid(2) does not return what one would expect.

I've been unable to build a linux program exhibiting the same  
behaviour myself, but I'm by far no linux expert.

Looks like either clone(2) or getpid(2) is seriously broken, isn't  
it? However, digging through the sources I can't find anything  
obviously wrong.

Same thing works correctly on NetBSD/32 in emul/linux.

Another point is I'm noting lots of "unknown errno x" with x being