I need this too, for SUBTERFUGUE, as well as the other patchlet that you(Pavel) just posted (waiting for clone and non-clone children simultaneously).

There are also three other patchlets that I believe are necessary if you wantto do really solid tracing (including clone). The particulars are availableat http://subterfugue.org/patches.html , but here is a brief rundown:

- Change do_fork so that clone children created with CLONE_PARENT are reparented correctly. This is just the logical thing--the current behavior is completely useless, as far as I can see. (There is a possible small security issue, which could be addressed if needed.)

- Set the high (0x80) bit of exit_code on PTRACE_SYSCALL stops. As far as I can tell, without this (or a variation), it's practically impossible to tell whether a stop in this case happened due to a syscall exit or a true SIGTRAP. (This change breaks existing versions of 'strace', but the fix is trivial.)

- Add a new command PTRACE_GETPPID which returns the original parent pid of a process. To see why this is needed, imagine that you're tracing a process as it goes through a fork. Suppose the child reports (at your wait4) first, as it is leaving the fork call. You know the child's pid, but there's no way to find out its original ppid. If you're following a set of processes, there may be many outstanding fork calls at any point, and when children start reporting, you want to be able to line them up with their parents.

An alternative (and better IMO) solution would be to have the *original* ppid reported everywhere (e.g., /proc/n/{stat,status}). The current behavior of making ptrace reparenting visible everywhere is arguably the wrong thing, as it confuses any processes that are watching.

I'd really like to have these in for 2.4, or hear objections so that I can tryto address them. Any advice at all on how to proceed would be welcome.