From mboxrd@z Thu Jan 1 00:00:00 1970 From: Scott James Remnant Date: Wed, 22 Oct 2008 16:22:30 +0000 Subject: Re: Report: Threaded udevd Message-Id: <1224692550.7588.11.camel@quest> MIME-Version: 1 Content-Type: multipart/mixed; boundary="=-oJEOUIPsa50iLU+aVYjz" List-Id: References: <48FF3458.6030909@tuffmail.co.uk> In-Reply-To: <48FF3458.6030909@tuffmail.co.uk> To: linux-hotplug@vger.kernel.org --=-oJEOUIPsa50iLU+aVYjz Content-Type: text/plain Content-Transfer-Encoding: quoted-printable On Wed, 2008-10-22 at 17:12 +0100, Alan Jenkins wrote: > > The pipe2() syscall allows you to specify flags for the returned file > > descriptors: > > > > pipe2 (&fds, O_CLOEXEC) > > =20 >=20 > Ah! I see how it's supposed to be used now. >=20 > pipe2 (&fds, O_CLOEXEC) > if (fork() =3D=3D 0) { > dup2(&fds[WRITE_END], STDOUT_FILENO); > /* insert call to fcntl to remove O_CLOEXEC */ > exec(program_name); >=20 You don't need the call to fcntl. From the dup2(2) manpage: The two descriptors do not share file descriptor flags (the close-= on- exec flag). The close-on-exec flag (FD_CLOEXEC; see fcntl(2)) for = the duplicate descriptor is off. So after you dup2() the writing end to standard output, standard output will not be closed on exec. Scott --=20 Scott James Remnant scott@canonical.com --=-oJEOUIPsa50iLU+aVYjz Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iEYEABECAAYFAkj/U0YACgkQSnQiFMl4yK7rbwCgmcXYrgk1jp6jkqL0sHpw5yZQ bKkAnif9rp/c/rpL63+V6nOs7oTWEAu9 =8sWe -----END PGP SIGNATURE----- --=-oJEOUIPsa50iLU+aVYjz--