From: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
To: linux-kernel@vger.kernel.org
Subject: Re: wait() and strace -f
Date: Thu, 20 Dec 2001 00:26:38 +0900 [thread overview]
Message-ID: <87zo4f1b9t.fsf@devron.myhome.or.jp> (raw)
In-Reply-To: <20011218021407.A1595@ping.be> <877krlc60x.fsf@devron.myhome.or.jp> <20011218211839.A4447@ping.be>
In-Reply-To: <20011218211839.A4447@ping.be>
Kurt Roeckx <Q@ping.be> writes:
> > Probably, it's feature (or bug) of strace. I'm seems, if strace has
^^^^^^
Sorry, s/strace/the trace process/
> > child, trace of a child is started before wait() of parent. Then,
> > exit() of child continue wait() of parent.
>
> If I understand what you're saying, sleep(1) in child1, and
> sleep(2) in the parent should fix the problem, which it doesn't.
>
> And it still doesn't explain why it only happens with 2 childs.
As far as I read the source, it seems strace is not counting the
zombie. And strace wait exit() of child2 before restarting the wait()
of parent.
strace parent child1 child2
zombie
sleep(1) sleep(10)
before wait()
trap wait()
before exit()
trap exit()
restart child2
run exit()
restart parent
run wait()
> Maybe I should have mentioned this before: the wait will clean up
> the first child at the time the second child dies, or atleast
> that's what wait() returns.
>
> > > if (!fork())
> > > {
> > > /* Child 1. */
> > sleep(2);
> > > return 0;
> > > }
> >
> > The above change is continued the parent after 2 seconds.
>
> I know that too, as I said, only when child 1 dies before the
> parent calls wait().
strace-4.4/process.c in strace_4.4-1.tar.gz
diff -u /tmp/t/strace-4.4/process.c.orig /tmp/t/strace-4.4/process.c
--- /tmp/t/strace-4.4/process.c.orig Fri Aug 3 20:51:28 2001
+++ /tmp/t/strace-4.4/process.c Wed Dec 19 08:20:05 2001
@@ -1349,7 +1349,7 @@
/* WTA: fix bug with hanging children */
if (!(tcp->u_arg[2] & WNOHANG) && tcp->nchildren > 0) {
/* There are traced children */
- tcp->flags |= TCB_SUSPENDED;
+ /* tcp->flags |= TCB_SUSPENDED; */
tcp->waitpid = tcp->u_arg[0];
}
}
Try the above patch. This restart wait() immediately. However, probably
it will break something of other. ;)
--
OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
prev parent reply other threads:[~2001-12-19 15:27 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-12-18 1:14 wait() and strace -f Kurt Roeckx
2001-12-18 15:32 ` OGAWA Hirofumi
[not found] ` <877krlc60x.fsf@devron.myhome.or.jp>
2001-12-18 20:18 ` Kurt Roeckx
2001-12-19 15:26 ` OGAWA Hirofumi [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87zo4f1b9t.fsf@devron.myhome.or.jp \
--to=hirofumi@mail.parknet.co.jp \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox