Date: Thu, 11 Feb 2010 00:22:43 +0530 From: Naveen Gujje <gujjenaveen@gmail.com> To: Andriy Gapon <avg@icyb.net.ua> Cc: Garrett Cooper <yanefbsd@gmail.com>, freebsd-hackers@freebsd.org Subject: Re: System() returning ECHILD error on FreeBSD 7.2 Message-ID: <39c945731002101052l16f390e4q95e82d12b5b5fde4@mail.gmail.com> In-Reply-To: <4B72F3C7.7060004@icyb.net.ua> References: <39c945731002100925i2e466768peac89cdef15463f2@mail.gmail.com> <7d6fde3d1002100952g1518bc36r371020260e81a8c3@mail.gmail.com> <4B72F3C7.7060004@icyb.net.ua>
next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, Feb 10, 2010 at 11:28 PM, Andriy Gapon <avg@icyb.net.ua> wrote:
> on 10/02/2010 19:52 Garrett Cooper said the following:
> > Isn't this section of the system(3) libcall essentially doing what
> > you want, s.t. you'll never be able to get the process status when you
> > call waitpid(2)?
> >
> > do {
> > pid = _wait4(savedpid, &pstat, 0, (struct rusage *)0);
> > } while (pid == -1 && errno == EINTR);
> > break;
> >
> > You typically get status via wait*(2) when using exec*(2) or via
> > the return codes from system(3), not system(3) with wait*(2)...
>
> Exactly. I think that SIGCHLD handler would effectively 'reap' the child
> and thus
> wait*() in system would rightfully return ECHILD (perhaps after doing EINTR
> iteration of the loop).
>
> Since we block SIGCHLD signal in system(3) till we return from wait4(), i
think there
is no way in which SIGCHLD handler gets invoked? Am I correct or Am I
missing something?
If I do the following then I don't see any problem
oldsa = signal(SIGCHLD, SIG_DFL);
if (0 != system(command))
exit(1);
signal(SIGCHLD, oldsa);
Thanks,
Naveen Gujje
--
> Andriy Gapon
>
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?39c945731002101052l16f390e4q95e82d12b5b5fde4>
