fixup! gluon-core: implement popen3() in gluon/util.lua
This commit is contained in:
parent
e2ec7f6e5c
commit
c1df15690b
@ -203,9 +203,9 @@ function M.popen3(policies, path, ...)
|
|||||||
local parentfds = {}
|
local parentfds = {}
|
||||||
|
|
||||||
for fd, policy in pairs(policies) do
|
for fd, policy in pairs(policies) do
|
||||||
if M.PipePolicies.CREATE==policy then
|
if policy==M.PipePolicies.CREATE then
|
||||||
local piper, pipew = posix_unistd.pipe()
|
local piper, pipew = posix_unistd.pipe()
|
||||||
if posix_unistd.STDIN_FILENO==fd then
|
if fd==posix_unistd.STDIN_FILENO then
|
||||||
childfds[fd]=piper
|
childfds[fd]=piper
|
||||||
parentfds[fd]=pipew
|
parentfds[fd]=pipew
|
||||||
else
|
else
|
||||||
@ -230,11 +230,11 @@ function M.popen3(policies, path, ...)
|
|||||||
end
|
end
|
||||||
|
|
||||||
for fd, policy in pairs(policies) do
|
for fd, policy in pairs(policies) do
|
||||||
if M.PipePolicies.DISCARD==policy then
|
if policy==M.PipePolicies.DISCARD then
|
||||||
if posix_unistd.STDIN_FILENO~=fd then
|
if fd~=posix_unistd.STDIN_FILENO then
|
||||||
posix_unistd.dup2(null, fd)
|
posix_unistd.dup2(null, fd)
|
||||||
end
|
end
|
||||||
elseif M.PipePolicies.CREATE==policy then
|
elseif policy==M.PipePolicies.CREATE then
|
||||||
-- only close these, if they exist
|
-- only close these, if they exist
|
||||||
posix_unistd.close(parentfds[fd])
|
posix_unistd.close(parentfds[fd])
|
||||||
posix_unistd.dup2(childfds[fd], fd)
|
posix_unistd.dup2(childfds[fd], fd)
|
||||||
|
Loading…
Reference in New Issue
Block a user