fixup! gluon-core: implement popen3() in gluon/util.lua
This commit is contained in:
parent
fd6c77d134
commit
12d2f3a252
@ -199,19 +199,18 @@ M.PipePolicies = {
|
|||||||
-- Execute a program found using command PATH search, like the shell.
|
-- Execute a program found using command PATH search, like the shell.
|
||||||
-- Return the pid, as well as the I/O streams as pipes or nil on error.
|
-- Return the pid, as well as the I/O streams as pipes or nil on error.
|
||||||
function M.popen3(policies, path, ...)
|
function M.popen3(policies, path, ...)
|
||||||
local pipes = {}
|
|
||||||
local intern = {}
|
local intern = {}
|
||||||
local extern = {}
|
local extern = {}
|
||||||
|
|
||||||
for fd, policy in pairs(policies) do
|
for fd, policy in pairs(policies) do
|
||||||
if M.PipePolicies.CREATE==policy then
|
if M.PipePolicies.CREATE==policy then
|
||||||
pipes[fd]={posix_unistd.pipe()}
|
local piper, pipew = posix_unistd.pipe()
|
||||||
if posix_unistd.STDIN_FILENO==fd then
|
if posix_unistd.STDIN_FILENO==fd then
|
||||||
intern[fd]=pipes[fd][1]
|
intern[fd]=piper
|
||||||
extern[fd]=pipes[fd][2]
|
extern[fd]=pipew
|
||||||
else
|
else
|
||||||
intern[fd]=pipes[fd][2]
|
intern[fd]=pipew
|
||||||
extern[fd]=pipes[fd][1]
|
extern[fd]=piper
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user