[Bug 208188] multiple identical wait4 results for ptraced processes

bugzilla-noreply at freebsd.org bugzilla-noreply at freebsd.org
Mon Mar 21 20:38:31 UTC 2016


https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=208188

            Bug ID: 208188
           Summary: multiple identical wait4 results for ptraced processes
           Product: Base System
           Version: 10.2-RELEASE
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Some People
          Priority: ---
         Component: kern
          Assignee: freebsd-bugs at FreeBSD.org
          Reporter: joss.upton at yahoo.com

Created attachment 168466
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=168466&action=edit
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.

-- 
You are receiving this mail because:
You are the assignee for the bug.


More information about the freebsd-bugs mailing list