From owner-freebsd-hackers Tue Oct 2 3:21: 5 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from ringworld.nanolink.com (straylight.ringlet.net [217.75.134.254]) by hub.freebsd.org (Postfix) with SMTP id 631B037B407 for ; Tue, 2 Oct 2001 03:20:55 -0700 (PDT) Received: (qmail 10234 invoked by uid 1000); 2 Oct 2001 10:09:42 -0000 Date: Tue, 2 Oct 2001 13:09:42 +0300 From: Peter Pentchev To: David Taylor Cc: Alfred Perlstein , freebsd-hackers@FreeBSD.org Subject: Re: Doubt of system(3) Message-ID: <20011002130942.C704@ringworld.oblivion.bg> Mail-Followup-To: David Taylor , Alfred Perlstein , freebsd-hackers@FreeBSD.org References: <200109291527.f8TFRrU76727.toshi@jp.FreeBSD.org> <20010929153433.U59854@elvis.mu.org> <20010929214338.A57903@gattaca.yadt.co.uk> <20010929221658.B57903@gattaca.yadt.co.uk> <20010929170332.Y59854@elvis.mu.org> <20010929232839.A91153@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: <20010929232839.A91153@gattaca.yadt.co.uk>; from davidt@yadt.co.uk on Sat, Sep 29, 2001 at 11:28:39PM +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 On Sat, Sep 29, 2001 at 11:28:39PM +0100, David Taylor wrote: [snip] > IMO, the below patch is probably the best solution. Yep, it also fixes the fact that the return value from wait4() needs to be preserved, at least for the return statement of __system(). G'luck, Peter -- "yields falsehood, when appended to its quotation." yields falsehood, when appended to its quotation. > > cvs diff: Diffing . > > Index: system.c > > =================================================================== > > RCS file: /home/ncvs/src/lib/libc/stdlib/system.c,v > > retrieving revision 1.7 > > diff -u -r1.7 system.c > > --- system.c 2001/01/24 13:00:59 1.7 > > +++ system.c 2001/09/29 21:55:41 > > @@ -53,7 +53,7 @@ > > __system(command) > > const char *command; > > { > > - pid_t pid; > > + pid_t pid, savedpid; > > int pstat; > > struct sigaction ign, intact, quitact; > > sigset_t newsigblock, oldsigblock; > > @@ -86,8 +86,9 @@ > > execl(_PATH_BSHELL, "sh", "-c", command, (char *)NULL); > > _exit(127); > > default: /* parent */ > > + savedpid = pid; > > do { > > - pid = _wait4(pid, &pstat, 0, (struct rusage *)0); > > + pid = _wait4(savedpid, &pstat, 0, (struct rusage *)0); > > } while (pid == -1 && errno == EINTR); > > break; > > } > > To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message