From owner-freebsd-hackers Sat Sep 29 13:43:48 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from mail.yadt.co.uk (yadt.demon.co.uk [158.152.4.134]) by hub.freebsd.org (Postfix) with SMTP id F143D37B40B for ; Sat, 29 Sep 2001 13:43:41 -0700 (PDT) Received: (qmail 3610 invoked from network); 29 Sep 2001 20:43:39 -0000 Received: from gattaca.local.yadt.co.uk (HELO mail.gattaca.yadt.co.uk) (qmailr@10.0.0.2) by xfiles.yadt.co.uk with SMTP; 29 Sep 2001 20:43:39 -0000 Received: (qmail 57979 invoked by uid 1000); 29 Sep 2001 20:43:38 -0000 Date: Sat, 29 Sep 2001 21:43:38 +0100 From: David Taylor To: freebsd-hackers@FreeBSD.org Subject: Re: Doubt of system(3) Message-ID: <20010929214338.A57903@gattaca.yadt.co.uk> Mail-Followup-To: freebsd-hackers@FreeBSD.org References: <200109291527.f8TFRrU76727.toshi@jp.FreeBSD.org> <20010929153433.U59854@elvis.mu.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-md5; protocol="application/pgp-signature"; boundary="vtzGhvizbBRQ85DL" Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <20010929153433.U59854@elvis.mu.org>; from bright@mu.org on Sat, Sep 29, 2001 at 15:34:33 -0500 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 --vtzGhvizbBRQ85DL Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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. > >=20 > > default: /* parent */ > > do { > > pid =3D _wait4(pid, &pstat, 0, (struct rusage *= )0); > > } while (pid =3D=3D -1 && errno =3D=3D EINTR); > > break; > >=20 > > Please review and commit this patch. >=20 > 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'. >=20 > What's a, b and c? >=20 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 [=3D11], ...); 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 =3D=3D -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...) --=20 David Taylor davidt@yadt.co.uk --vtzGhvizbBRQ85DL Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (FreeBSD) Comment: For info see http://www.gnupg.org iD8DBQE7tjJ6fIqKXSsJ/xERAmxIAJ9L/wXrlMIVp8+OOzXNvcXL7nZsGwCeLQdC /8JrSSOGQ0YSKudT/LDA7wI= =ecRM -----END PGP SIGNATURE----- --vtzGhvizbBRQ85DL-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message