main/lua-posix: add cloexec support

cherry-pick patch from git master (with readme update removed)
This commit is contained in:
Timo Teräs 2015-09-02 13:44:50 +03:00
parent f984c36702
commit 599e6b2a70
2 changed files with 85 additions and 4 deletions

View File

@ -5,7 +5,7 @@ _luaversions="5.1 5.2 5.3"
pkgname=lua-posix
_name=luaposix
pkgver=33.3.1
pkgrel=2
pkgrel=3
pkgdesc="POSIX library for Lua $_luaver"
url="https://github.com/luaposix/luaposix"
arch="all"
@ -21,6 +21,7 @@ for _i in $_luaversions; do
done
source="luaposix-$pkgver.tar.gz::https://github.com/luaposix/luaposix/archive/release-v$pkgver.tar.gz
fix-sched-header.patch
add-cloexec.patch
"
_sdir="$srcdir"/$_name-release-v$pkgver
@ -103,8 +104,11 @@ for _i in $_luaversions; do
done
md5sums="1d07112a5582b539930066d7c834643f luaposix-33.3.1.tar.gz
d4165a01aa0d606315a35cbb956ed763 fix-sched-header.patch"
d4165a01aa0d606315a35cbb956ed763 fix-sched-header.patch
b5420275eb73d12514a4b95cc9ae8923 add-cloexec.patch"
sha256sums="49e1eda64d0c03d0f2977fc1e04ce8c620dc3bb9a5c54c342904751d21b1b3cf luaposix-33.3.1.tar.gz
b49102e3c08418c6298f4ce4cea1856082e17e016551c16633851e35de115128 fix-sched-header.patch"
b49102e3c08418c6298f4ce4cea1856082e17e016551c16633851e35de115128 fix-sched-header.patch
375d23dce99da756927563f1e1511fe61bb11c2170284ce2bf5f8b9fc956f6ca add-cloexec.patch"
sha512sums="76d4d9feb44f857a98dd3ad76d8ca4e4f917a4f75b04e72fdce70b092aa825a91a51cb19cf8046cbe551a92e281008664ef103301543756a646e7bab31538e33 luaposix-33.3.1.tar.gz
2b80759b1803059c1424ad7564ff8ec70aeff85faf817db1f2fc09b7bab3deac2fd5f98de78657039b39b9817d8978c9a382fb687975e381e95c369389b76b2a fix-sched-header.patch"
2b80759b1803059c1424ad7564ff8ec70aeff85faf817db1f2fc09b7bab3deac2fd5f98de78657039b39b9817d8978c9a382fb687975e381e95c369389b76b2a fix-sched-header.patch
3f61742bed2f5114d0a4c1f32446901d9664ed44a03344e3cdac4e41727a91871fc13a397338b0bd24a7a859466c712dc238e48a32dffe89635044abf94d69e2 add-cloexec.patch"

View File

@ -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