Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 30 Mar 2005 20:28:29 +0200
From:      Florent Thoumie <flz@xbsd.org>
To:        zean zean <fbsd.hackers@gmail.com>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: the best form to wait the finish of execution of a child...
Message-ID:  <1112207309.761.15.camel@cream.xbsd.org>
In-Reply-To: <a9e342b5050330101771e53d6f@mail.gmail.com>
References:  <a9e342b5050330101771e53d6f@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help

--=-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--



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