Bug 2774 - waitpid() returns status twice from threaded fork()
Summary: waitpid() returns status twice from threaded fork()
Status: RESOLVED WONTFIX
Alias: None
Product: frysk
Classification: Unclassified
Component: general (show other bugs)
Version: unspecified
: P3 normal
Target Milestone: ---
Assignee: Andrew Cagney
URL:
Keywords:
Depends on:
Blocks: 1496
  Show dependency treegraph
 
Reported: 2006-06-14 21:03 UTC by Mike Cvet
Modified: 2006-06-15 17:38 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mike Cvet 2006-06-14 21:03:28 UTC
When waitpid() is called from a threaded parent process on a child, the status
of the child is returned twice; once to the parent of the process itself, and
the second to the parent thread, currently involved in a ptrace operation on
that child process.

Is it possible that these two are returned in such a way that another child
exiting results in its status being returned inbetween the two returns from the
other child? A race condition in the kernel?
Comment 1 Andrew Cagney 2006-06-15 17:38:09 UTC
Yes, on the 2.6 linux kernel, with the current ptrace implementation, when a
non-main thread forks a trace-me child, and the main thread is doing waitpid,
the child's exit creates two wait events:

1. for the parent of the child as it exited
Because the tracing thread is not the main thread.
1. for the ptrace-ing process because the target exited
Because the main thread is not the tracing thread.

cute "feature" eh?