Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 2 Oct 2001 13:09:42 +0300
From:      Peter Pentchev <roam@ringlet.net>
To:        David Taylor <davidt@yadt.co.uk>
Cc:        Alfred Perlstein <bright@mu.org>, freebsd-hackers@FreeBSD.org
Subject:   Re: Doubt of system(3)
Message-ID:  <20011002130942.C704@ringworld.oblivion.bg>
In-Reply-To: <20010929232839.A91153@gattaca.yadt.co.uk>; from davidt@yadt.co.uk on Sat, Sep 29, 2001 at 11:28:39PM %2B0100
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>

next in thread | previous in thread | raw e-mail | index | archive | help
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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20011002130942.C704>