diff options
Diffstat (limited to 'main/lua-posix/add-cloexec.patch')
-rw-r--r-- | main/lua-posix/add-cloexec.patch | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/main/lua-posix/add-cloexec.patch b/main/lua-posix/add-cloexec.patch new file mode 100644 index 0000000000..927c66ec63 --- /dev/null +++ b/main/lua-posix/add-cloexec.patch @@ -0,0 +1,77 @@ +From 659b3b242dae04a4b958759d414716ce95c27230 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Timo=20Ter=C3=A4s?= <timo.teras@iki.fi> +Date: Sat, 4 Jul 2015 17:02:55 +0100 +Subject: [PATCH] fcntl: add constants FD_CLOEXEC, and O_CLOEXEC where + supported. + +Close #227. +* ext/posix/fcntl.c (O_CLOEXEC): Default to `0` when not defined +by underlying system so that it can be ORed successfully. +(open): Note O_CLOEXEC in LDocs. +(O_CLOEXEC, FD_CLOEXEC): Define as Lua constants. + +Signed-off-by: Gary V. Vaughan <gary@gnu.org> +--- + ext/posix/fcntl.c | 13 +++++++++++-- + 2 files changed, 27 insertions(+), 3 deletions(-) + +diff --git a/ext/posix/fcntl.c b/ext/posix/fcntl.c +index e702241..5eaef10 100644 +--- a/ext/posix/fcntl.c ++++ b/ext/posix/fcntl.c +@@ -33,6 +33,10 @@ + #ifndef O_DSYNC + #define O_DSYNC 0 + #endif ++/* POSIX.2001 uses FD_CLOEXEC instead. */ ++#ifndef O_CLOEXEC ++#define O_CLOEXEC 0 ++#endif + + + +@@ -110,7 +114,7 @@ Open a file. + @string path + @int oflags bitwise OR of zero or more of `O_RDONLY`, `O_WRONLY`, `O_RDWR`, + `O_APPEND`, `O_CREAT`, `O_DSYNC`, `O_EXCL`, `O_NOCTTY`, `O_NONBLOCK`, +- `O_RSYNC`, `O_SYNC`, `O_TRUNC` ++ `O_RSYNC`, `O_SYNC` and `O_TRUNC` (and `O_CLOEXEC`, where supported) + @int[opt=511] mode access modes used by `O_CREAT` + @treturn[1] int file descriptor for *path*, if successful + @return[2] nil +@@ -179,8 +183,10 @@ Constants. + + /*** + Fcntl constants. +-Any constants not available in the underlying system will be `nil` valued. ++Any constants not available in the underlying system will be `0` valued, ++if they are usually bitwise ORed with other values, otherwise `nil`. + @table posix.fcntl ++@int FD_CLOEXEC close file descriptor on exec flag + @int F_DUPFD duplicate file descriptor + @int F_GETFD get file descriptor flags + @int F_SETFD set file descriptor flags +@@ -198,6 +204,7 @@ Any constants not available in the underlying system will be `nil` valued. + @int O_WRONLY open for writing only + @int O_RDWR open for reading and writing + @int O_APPEND set append mode ++@int O_CLOEXEC set FD_CLOEXEC atomically + @int O_CREAT create if nonexistent + @int O_DSYNC synchronise io data integrity + @int O_EXCL error if file already exists +@@ -229,6 +236,7 @@ luaopen_posix_fcntl(lua_State *L) + lua_setfield(L, -2, "version"); + + /* fcntl flags */ ++ LPOSIX_CONST( FD_CLOEXEC ); + LPOSIX_CONST( F_DUPFD ); + LPOSIX_CONST( F_GETFD ); + LPOSIX_CONST( F_SETFD ); +@@ -256,6 +264,7 @@ luaopen_posix_fcntl(lua_State *L) + LPOSIX_CONST( O_RSYNC ); + LPOSIX_CONST( O_SYNC ); + LPOSIX_CONST( O_TRUNC ); ++ LPOSIX_CONST( O_CLOEXEC ); + + /* posix_fadvise flags */ + #ifdef POSIX_FADV_NORMAL |