[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: CLOEXEC safety
- From: Sean Conner <sean@...>
- Date: Thu, 19 Nov 2015 11:49:55 -0500
It was thus said that the Great Daurnimator once stated:
> Hi all,
>
> I've been thinking about safely spawning processes in a multithreaded
> program lately.
> The opinion of POSIX seems to be that `closefrom` is wrong, and that
> well-written programs and libraries should always open fd with
> O_CLOEXEC set from the start.
> To aid this, the "e" specifier to fopen (currently a gnu extension) is
> to be featured in the next POSIX standard.
> This "e" flag has been widely supported by libcs on posix systems for
> many years.
> This same feature is available on windows as the "N" flag to fopen.
>
> To prevent issues in multi-threaded applications that use lua,
> I suggest that lua automatically append the relevant flag to the fopen 'mode'.
> i.e. "e" on POSIX systems and "N" on windows.
And what if I *want* to pass an open file to a child process? How do I
specify to Lua that I *don't* want this behavior?
-spc (or is stdin, stdout and stderr only allowed to remain open in a
child process?)