[vlc-devel] [PATCH] Don't assume O_CLOEXEC is defined

Rafaël Carré rafael.carre at gmail.com
Thu Jan 5 01:55:47 CET 2012

Le 2012-01-04 19:16, Pierre Ynard a écrit :
>>>> Perhaps it could go in vlc_fs.h as
>>>> #ifndef O_CLOEXEC
>>>> # define O_CLOEXEC 0
>>>> #endif
> That looks like a better approach to me.

This flag is only used in s/posix/filesystem.c and m/access/dtv/linux.c

>>> Linux support for close-on-exec is in the kernel, not libc. And
>>> that is irrelevant. What is relevant is your patch brings back a
>>> well-known annoying old bug, leaking of device nodes through child
>>> processes.
>> The flag is actually used where possible .. so it's not "bringing back"
>> a bug, but let VLC build (and leak device nodes through child processes)
>> on systems without O_CLOEXEC.
> I think that if O_CLOEXEC is unavailable, you can still try setting
> FD_CLOEXEC with fcntl(). That leaves a race condition, but that's for
> fixing this very issue that O_CLOEXEC is needed.

Thanks, I had missed that FD_CLOEXEC is available everywhere.

I propose another patch to reuse the existing logic, and thus using
O_CLOEXEC only inside posix/filesystem.c

More information about the vlc-devel mailing list