Re: Report: Threaded udevd

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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)
> >   
> 
> Ah!  I see how it's supposed to be used now.
> 
> pipe2 (&fds, O_CLOEXEC)
> if (fork() == 0) {
>    dup2(&fds[WRITE_END], STDOUT_FILENO);
>    /* insert call to fcntl to remove O_CLOEXEC */
>    exec(program_name);
> 
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
-- 
Scott James Remnant
scott@xxxxxxxxxxxxx

Attachment: signature.asc
Description: This is a digitally signed message part


[Index of Archives]     [Linux Kernel]     [Linux DVB]     [Asterisk Internet PBX]     [DCCP]     [Netdev]     [X.org]     [Util Linux NG]     [Fedora Women]     [ALSA Devel]     [Linux USB]

  Powered by Linux