There seems to be a race condition between the pipe closing and the child process death. Likely these two events are not atomic on some versions of linux.
With the removal of WNOHANG we eliminate the race condition, however if the child closes the pipe intentionally then it could result in the test runner hanging. I find this situation less likely, where as I experience failures locally with this race condition rather consistently.
BTW, it is worth adding a comment here that Pid will not be recycled until the call to waitpid and so waiting on it is safe even after the process actually exits. Every time I read code like this, I end up having to Google for Pid recycling rules.