Proposed manpage additions for ptrace(2)
In-Reply-To: <[email protected]>
Quoted 21 lines · Daniel Jacobowitz
Quoted 14 lines
PTRACE_O_TRACEFORK
Stop the child at the nextfork()call with SIGTRAP |PTRACE_EVENT_FORK<< 8 and automatically start tracing the newly forked process, which will start with a
SIGSTOP. The pid for the new process can be retrieved
withPTRACE_GETEVENTMSG.
PTRACE_O_TRACEVFORK
Stop the child at the nextvfork()call with SIGTRAP |PTRACE_EVENT_VFORK<< 8 and automatically start tracing the the newly vforked process, which will start with a
SIGSTOP. The pid for the new process can be retrieved
withPTRACE_GETEVENTMSG.Quoted 6 lines
PTRACE_O_TRACECLONE
Stop the child at the nextclone()call with SIGTRAP |PTRACE_EVENT_CLONE<< 8 and automatically start tracing the newly cloned process, which will start with a
SIGSTOP. The pid for the new process can be retrieved
withPTRACE_GETEVENTMSG.
Quoted 7 lines
Specifically, the three kinds of cloning are distinguished as:
if
CLONE_VFORK->PTRACE_EVENT_VFORK
else if clone exit signal == SIGCHLD ->PTRACE_EVENT_FORKelsePTRACE_EVENT_CLONEYou need to do some juggling to get the actual clone flags.
It might be best to leave these descriptions in terms of C library functions rather than kernel-internal. Looking at sys_clone() and sys_fork() I can see what you mean but I'm not sure how to describe it to a programmer.
Quoted 3 lines
BTW, I believe there are still some potential deadlocks between the vfork event and the vfork done event; I used to regularly generate unkillable processes working on this code.
I have a test program and didn't hit any problems yet. Maybe this was fixed?
Signature · 2 lines
Chuck "Penguins don't come from next door, they come from the Antarctic!"
Quoted 11 lines · Chuck Ebbert
Quoted 7 lines
Specifically, the three kinds of cloning are distinguished as:
if
CLONE_VFORK->PTRACE_EVENT_VFORK
else if clone exit signal == SIGCHLD ->PTRACE_EVENT_FORKelsePTRACE_EVENT_CLONEYou need to do some juggling to get the actual clone flags.
It might be best to leave these descriptions in terms of C library functions rather than kernel-internal. Looking at
sys_clone()andsys_fork()I can see what you mean but I'm not sure how to describe it to a programmer.
Those are user accessible flags. Fork will give you a PTRACE_EVENT_FORK, vfork will give you a PTRACE_EVENT_VFORK, but clone may give you any of the above, depending on what arguments you pass to it. The SIGCHLD test matches the bit described in clone(2) for __WALL or __WCLONE, for instance.
Quoted 5 lines
Quoted 3 lines
BTW, I believe there are still some potential deadlocks between the vfork event and the vfork done event; I used to regularly generate unkillable processes working on this code.
I have a test program and didn't hit any problems yet. Maybe this was fixed?
One thing that IIRC was a problem was killing the parent before the child (or maybe the other way round) when stopped at this point - such as would happen if you typed "kill" at a GDB prompt after catch vfork.
Signature · 2 lines
Daniel Jacobowitz CodeSourcery