From owner-freebsd-hackers@FreeBSD.ORG Wed Mar 30 18:28:35 2005 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id E2EAF16A4CE for ; Wed, 30 Mar 2005 18:28:35 +0000 (GMT) Received: from smtp.xbsd.org (xbsd.org [82.233.2.192]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8E51243D5A for ; Wed, 30 Mar 2005 18:28:35 +0000 (GMT) (envelope-from flz@xbsd.org) Received: from localhost (localhost.xbsd.org [127.0.0.1]) by smtp.xbsd.org (Postfix) with ESMTP id 4E1F9114BE; Wed, 30 Mar 2005 20:31:00 +0200 (CEST) Received: from smtp.xbsd.org ([127.0.0.1]) by localhost (srv1.xbsd.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 77706-02; Wed, 30 Mar 2005 20:30:51 +0200 (CEST) Received: from cream.xbsd.org (cream.xbsd.org [192.168.42.6]) by smtp.xbsd.org (Postfix) with ESMTP id B3757114A2; Wed, 30 Mar 2005 20:30:50 +0200 (CEST) From: Florent Thoumie To: zean zean In-Reply-To: References: Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=-MWIT1vZ14wuqb69n378u" Date: Wed, 30 Mar 2005 20:28:29 +0200 Message-Id: <1112207309.761.15.camel@cream.xbsd.org> Mime-Version: 1.0 X-Mailer: Evolution 2.2.1.1 FreeBSD GNOME Team Port X-Virus-Scanned: amavisd-new at xbsd.org cc: freebsd-hackers@freebsd.org Subject: Re: the best form to wait the finish of execution of a child... X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 Mar 2005 18:28:36 -0000 --=-MWIT1vZ14wuqb69n378u Content-Type: text/plain; charset=iso8859-15 Content-Transfer-Encoding: quoted-printable Le Mercredi 30 mars 2005 =E0 14:17 -0400, zean zean a =E9crit : > Hi Hackers: >=20 > Excuse for my badly English. which is the best form to wait the > finish of execution of a child. It depends on the context of your program=20 (synchronous/asynchronous). > My idea is: >=20 > pid_t chilpid; >=20 > while(childpid !=3D wait(&status)) > ; That's a possibility, you can catch SIGCHLD with a signal=20 handler (see signal(3), sigprocmask(2), sigaction(2)) which=20 would set a global flag, and then use a non-blocking waitpid(2)=20 or wait4(2) instead. Note: What you suggested isn't really safe. You shouldn't=20 ignore wait(2) return status (could be -1 because something unexpected happened, see ERRORS section from the manpage). --=20 Florent Thoumie flz@xbsd.org --=-MWIT1vZ14wuqb69n378u Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (FreeBSD) iD8DBQBCSu/NMxEkbVFH3PQRAucgAJwM2h60Y7KbZdCgcBi01W1C+ulhigCfbsDE 9zmy7UyCzLSmX2Aetf2wu2A= =uMXj -----END PGP SIGNATURE----- --=-MWIT1vZ14wuqb69n378u--