[PATCH] Assume that O_CLOEXEC is always defined and works

Florian Weimer fweimer@redhat.com
Tue Apr 18 09:39:00 GMT 2017


On 04/17/2017 09:11 PM, Adhemerval Zanella wrote:
>>     if (!do_cloexec)
>> -#ifdef O_CLOEXEC
>>       /* Undo the effects of the pipe2 call which set the
>>          close-on-exec flag.  */
>>       __fcntl (parent_end, F_SETFD, 0);
>> -#endif

> Why can't we issue the __pipe2 as '__pipe2 (pipe_fds, do_cloexec ? O_CLOEXEC : 0)'
> and get rid of this logic here?

There are two descriptors.  The descriptor for the subprocess must 
always be O_CLOEXEC in the parent, so that it's not captured by a 
concurrent fork and inherited across execve there.

Thanks,
Florian



More information about the Libc-alpha mailing list