From owner-freebsd-hackers Sat Sep 29 14: 5: 3 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from elvis.mu.org (elvis.mu.org [216.33.66.196]) by hub.freebsd.org (Postfix) with ESMTP id A99F237B40C for ; Sat, 29 Sep 2001 14:05:00 -0700 (PDT) Received: by elvis.mu.org (Postfix, from userid 1192) id 9890281D0B; Sat, 29 Sep 2001 16:05:00 -0500 (CDT) Date: Sat, 29 Sep 2001 16:05:00 -0500 From: Alfred Perlstein To: David Taylor Cc: freebsd-hackers@FreeBSD.org Subject: Re: Doubt of system(3) Message-ID: <20010929160500.X59854@elvis.mu.org> References: <200109291527.f8TFRrU76727.toshi@jp.FreeBSD.org> <20010929153433.U59854@elvis.mu.org> <20010929214338.A57903@gattaca.yadt.co.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <20010929214338.A57903@gattaca.yadt.co.uk>; from davidt@yadt.co.uk on Sat, Sep 29, 2001 at 09:43:38PM +0100 Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG * David Taylor [010929 15:44] wrote: > On Sat, 29 Sep 2001, Alfred Perlstein wrote: > > * Toshihiko ARAI [010929 11:10] wrote: > > > I consider the following code of system(3). pid is changed by return > > > value of _wait4(). I feel this need a correction. > > > > > > default: /* parent */ > > > do { > > > pid = _wait4(pid, &pstat, 0, (struct rusage *)0); > > > } while (pid == -1 && errno == EINTR); > > > break; > > > > > > Please review and commit this patch. > > > > Why does it need to be corrected? What sort of bad behaviour > > are you seeing? You do 'a' and you see 'b' when you should > > see 'c'. > > > > What's a, b and c? > > > > Well, hypothetically (I have no time to attempt to set something up to test > this), it looks to me like: > > If you: > > 1. Fork, and create a child (say, pid 10) > 2. Call system, which forks and creates a child (say, pid 11) > 3. Make the child (pid 10) exit now. > 3. Interrupt the call to _wait4(pid [=11], ...); > > You _should_ see nothing happen. i.e. system() would simply loop again > until the other child exits. > > However, what I think you'd see is system() setting pid == -1, calling > _wait4(-1, ...); and _wait4() returning 10, and system() returning whilst > your child is still running happily away. > > If I run out of bugs to squash in ircd, I might try to produce this (I > suppose reproduce is the wrong word, since no one has reported it in the > first place...) Yes, makes sense. -- -Alfred Perlstein [alfred@freebsd.org] 'Instead of asking why a piece of software is using "1970s technology," start asking why software is ignoring 30 years of accumulated wisdom.' To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message