fixup! gluon-core: implement popen3() in gluon/util.lua

This commit is contained in:
aiyion.prime 2021-07-11 18:08:11 +02:00
parent 939720deb9
commit 63d4409316

View File

@ -226,14 +226,12 @@ function M.subprocess.popen(policies, path, ...)
local null = -1 local null = -1
if M.contains(policies, M.subprocess.DEVNULL) then if M.contains(policies, M.subprocess.DEVNULL) then
-- only open, if there's anything to discard -- only open, if there's anything to discard
null = posix_fcntl.open('/dev/null', posix_fcntl.O_WRONLY) null = posix_fcntl.open('/dev/null', posix_fcntl.O_RDWR)
end end
for fd, policy in pairs(policies) do for fd, policy in pairs(policies) do
if policy == M.subprocess.DEVNULL then if policy == M.subprocess.DEVNULL then
if fd ~= posix_unistd.STDIN_FILENO then posix_unistd.dup2(null, fd)
posix_unistd.dup2(null, fd)
end
elseif policy == M.subprocess.PIPE then elseif policy == M.subprocess.PIPE then
-- only close these, if they exist -- only close these, if they exist
posix_unistd.close(parentfds[fd]) posix_unistd.close(parentfds[fd])