Kurt Roeckx <Q@ping.be> writes:
> int main()
> {
> int i;
>
> if (!fork())
> {
> /* Child 1. */
> return 0;
> }
>
> if (!fork())
> {
> /* Child 2. */
> sleep(10);
> return 0;
> }
>
> /* Parent. */
> sleep(1);
> wait(&i);
> return 0;
> }
>
> Without strace -f, this program stops after 1 second and the
> second child still lives for 9 seconds. With strace -f this
> program stops after 10 second after the second child died.
>
> I think it's related to strace being the "real" parent of the
> child. But that doesn't really explain why I need 2 childs.
Probably, it's feature (or bug) of strace. If the trace process has
child, trace of a child is continued before wait() of parent. Then,
exit() of the child process continue wait() of parent.
> if (!fork())
> {
> /* Child 1. */
sleep(2);
> return 0;
> }
The above continued the parent after 2 seconds.
-- OGAWA Hirofumi <hirofumi@mail.parknet.co.jp> - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
This archive was generated by hypermail 2b29 : Sun Dec 23 2001 - 21:00:16 EST