From owner-freebsd-hackers@FreeBSD.ORG Wed Feb 10 18:52:44 2010 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A3F3C1065670 for ; Wed, 10 Feb 2010 18:52:44 +0000 (UTC) (envelope-from gujjenaveen@gmail.com) Received: from mail-px0-f203.google.com (mail-px0-f203.google.com [209.85.216.203]) by mx1.freebsd.org (Postfix) with ESMTP id 771C38FC14 for ; Wed, 10 Feb 2010 18:52:44 +0000 (UTC) Received: by pxi41 with SMTP id 41so164470pxi.27 for ; Wed, 10 Feb 2010 10:52:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type; bh=Hz6XQPGBNw5JPhjKnRtTNLR7J/qdEbRvZw69TJ2+i+A=; b=Oj/VxvFreB/rtmegoL+SLzC3Ma8jau4wSZbu043lqL9G6nyK7zXZCFxZWjs23YP+EX s1x1z430nGR8yhIR8Uil9l4Akrq9MTxqwM2YIGX0SjyufsWFyC1sipAXRw2Y4Pncgf0H 0cbFsbrcU/AkcyPJF3L2nkltmdmwu6WP8GgLk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=uLS8hqsMivdGkpDiLz4GW+MYcijBv04R3wTRyGOpzaMF0dCZqdEnpUiHYlGVgmGklB 4VbDf/Sl471sZm4ywbURsHb2OiiB9Mks0UVEJwkRxXiUfrzup2jlEls8bBtspi+oFdSq msj2iCZFL/Tr2kONmo8nqLGOtYLIzKrz2UQGk= MIME-Version: 1.0 Received: by 10.141.23.19 with SMTP id a19mr424128rvj.22.1265827963894; Wed, 10 Feb 2010 10:52:43 -0800 (PST) In-Reply-To: <4B72F3C7.7060004@icyb.net.ua> References: <39c945731002100925i2e466768peac89cdef15463f2@mail.gmail.com> <7d6fde3d1002100952g1518bc36r371020260e81a8c3@mail.gmail.com> <4B72F3C7.7060004@icyb.net.ua> Date: Thu, 11 Feb 2010 00:22:43 +0530 Message-ID: <39c945731002101052l16f390e4q95e82d12b5b5fde4@mail.gmail.com> From: Naveen Gujje To: Andriy Gapon Content-Type: text/plain; charset=ISO-8859-1 X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Cc: Garrett Cooper , freebsd-hackers@freebsd.org Subject: Re: System() returning ECHILD error on FreeBSD 7.2 X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 10 Feb 2010 18:52:44 -0000 On Wed, Feb 10, 2010 at 11:28 PM, Andriy Gapon 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 >