Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLOEXEC related tweaks #1349

Merged
merged 2 commits into from
Apr 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ffi/input_pocketbook.lua
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ function input:open()
-- You must chmod those to be readable by non-root somehow (or run as root)
for i=1, max_fds-1 do
local input_dev = "/dev/input/event"..tostring(i)
local fd = C.open(input_dev, C.O_RDONLY+C.O_NONBLOCK)
local fd = C.open(input_dev, bit.bor(C.O_RDONLY, C.O_NONBLOCK, C.O_CLOEXEC))
if fd >= 0 then
poll_fds[poll_fds_count].fd = fd
poll_fds[poll_fds_count].events = C.POLLIN
Expand Down
2 changes: 1 addition & 1 deletion ffi/jpeg.lua
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ function Jpeg.encodeToFile(filename, source_ptr, w, stride, h, quality, color_ty
if turbojpeg.tjCompress2(handle, source_ptr, w, stride, h, color_type,
jpeg_image, jpeg_size, subsample, quality, 0) == 0 then

local fhandle = C.open(filename, bit.bor(C.O_WRONLY, C.O_CREAT, C.O_TRUNC), ffi.cast("int", bit.bor(C.S_IRUSR, C.S_IWUSR, C.S_IRGRP, C.S_IROTH)))
local fhandle = C.open(filename, bit.bor(C.O_WRONLY, C.O_CREAT, C.O_TRUNC, C.O_CLOEXEC), ffi.cast("int", bit.bor(C.S_IRUSR, C.S_IWUSR, C.S_IRGRP, C.S_IROTH)))
if fhandle >= 0 then
C.write(fhandle, jpeg_image[0], jpeg_size[0])
C.close(fhandle)
Expand Down
4 changes: 2 additions & 2 deletions ffi/kobolight.lua
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ function kobolight.open(device)
light_fd = nil,
}

local ld = C.open(device or "/dev/ntx_io", bor(bor(C.O_RDONLY, C.O_NONBLOCK), C.O_CLOEXEC))
assert(ld ~= -1, "cannot open light device")
local ld = C.open(device or "/dev/ntx_io", bor(C.O_RDONLY, C.O_NONBLOCK, C.O_CLOEXEC))
assert(ld ~= -1, "cannot open ntx_io character device")
light.light_fd = ffi.gc(
ffi.new("light_fd", ld),
function (light_fd) C.close(light_fd.ld) end
Expand Down
2 changes: 1 addition & 1 deletion ffi/util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ function util.fsyncDirectory(path)
return false, err
end
end
local dirfd = C.open(ffi.cast("char *", path), C.O_RDONLY)
local dirfd = C.open(ffi.cast("char *", path), bit.bor(C.O_RDONLY, C.O_CLOEXEC))
if dirfd == -1 then
err = ffi.errno()
return false, ffi.string(C.strerror(err))
Expand Down
4 changes: 4 additions & 0 deletions thirdparty/kpvcrlib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ else()
add_definitions(-DLINUX=1 -D_LINUX=1)
endif()

if(DEFINED ENV{LEGACY})
add_definitions(-DDISABLE_CLOEXEC)
endif()

add_definitions(
-DUSE_FONTCONFIG=0
-DUSE_FREETYPE=1
Expand Down