This small program demonstrates the failure.
It spawns a child which issues PTRACE_TRACEME and then raises SIGSTOP (which will be trapped by the parent).
The parent waits for the child with WNOWAIT to get the details early, this will spin at 100% CPU.
Remove the "| WNOWAIT" (and the additional waitid call just below) and it will work as expected.
This small program demonstrates the failure.
It spawns a child which issues PTRACE_TRACEME and then raises SIGSTOP (which will be trapped by the parent).
The parent waits for the child with WNOWAIT to get the details early, this will spin at 100% CPU.
Remove the "| WNOWAIT" (and the additional waitid call just below) and it will work as expected.