The debugger like truss(1) depends on the wait(2) syscall. This syscall
waits for ALL children. When it is waiting for ALL child's the children
created by process descriptors are not returned. This behavior was
introduced because we want to implement libraries which may pdfork(1).
The behavior of process descriptor brakes truss(1) because it will
not be able to collect the status of processes with process descriptors.
To address this problem the status is returned to parent when the
child is traced. While the process is traced the debugger is the parent.
The new process flag (P2_EXIT_TRACED) is introduced.
This flag informs that process exited while being traced.
Otherwise, the debugger will not collect the exit code of the traced process.
Unfortunately, that is not possible because of the kern_wait6().
This function again reparents the process to the original state.
If the P_TRACE flag would be set, the process would be added to
the orphan list of the debugger process - which would cause crash.
Add test case to verify that. The test case was implemented by markj@.