[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: luajit fdopen luaposix
- From: Mike Belopuhov <mike.belopuhov@...>
- Date: Thu, 26 Nov 2015 11:57:17 +0100
On Thu, Nov 26, 2015 at 11:44 +0100, Mike Belopuhov wrote:
> > [1] lunix is thread-safe[2], provides common extensions not defined by POSIX
> > (with custom implementations if needed to make them "portable"), and is
> > regularly tested on many non-Linux platforms--AIX, OS X, Solaris, and
> > several different BSDs.
> >
> > [2] At least as much as possible. The LuaJIT hack, for example, doesn't
> > permit properly emulating the "x" (O_CLOEXEC) flag to fdopen, which could
> > allow the temporary descriptor to be unintentionally inherited if another
> > thread calls forks at the same time. Although I just realized that LuaJIT
> > doesn't appear to check the contents of mode, so I should probably try to
> > pass it through. (And maybe also add a runtime check to see if the x flag is
> > supported by libc.)
> >
>
> The lack of explicit CLOEXEC handling can be circumvented by calling
> posix.fcntl with a F_SETFD and FD_CLOEXEC. This is a POSIX interface:
> http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/fcntl.h.html
> and is implemented by luaposix since Jul 4, 2015.
>
Just to clarify this a bit: I've realised that lunix is an
alternative to luaposix after writing this (-: