Created attachment 168466 [details] waitx2.c demonstrate the multiple / identical wait4() results. When ptrace'n a process, wait4() returns the same pid/status multiple times. This is when a process is ptrace'd, it gets a new parent and saves its old parent (in my case both the new parent and the old are the same process). Then, in proc_reap() called from, e.g. wait4(), the ptrace'd process is reparented back to its "real" parent and an additional SIGCHLD is generated. The attached program demonstrates the problem... On 10.2 it produces output like: 0: pid=1348 stopped(5) 1: pid=1348 exited(0) 2: pid=1348 exited(0) It's impossible to differentiate between 1 & 2 unless I go out of my way to remember that I've already seen process 1348 WIFEXITED or WIFSIGNALED before. The fix is to catch the superfluous SIGCHLD (when the realparent is the process currently waiting on the process) and stub it out. Patch and example program attached.
Created attachment 168467 [details] patch to not generate multiple SIGCHLDs in some cases
This bug is fixed with r283282.