From a125242f4c86c39fca25a26ea474721260e3bb0f Mon Sep 17 00:00:00 2001 From: "aiyion.prime" Date: Tue, 13 Jul 2021 09:15:58 +0200 Subject: [PATCH] fixup! gluon-core: implement popen3() in gluon/util.lua --- package/gluon-core/luasrc/usr/lib/lua/gluon/util.lua | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/package/gluon-core/luasrc/usr/lib/lua/gluon/util.lua b/package/gluon-core/luasrc/usr/lib/lua/gluon/util.lua index 73f6de75..9f5b4b32 100644 --- a/package/gluon-core/luasrc/usr/lib/lua/gluon/util.lua +++ b/package/gluon-core/luasrc/usr/lib/lua/gluon/util.lua @@ -200,9 +200,10 @@ M.subprocess.PIPE = 1 function M.subprocess.popen(path, argt, options) local childfds = {} local parentfds = {} + local stdiostreams = {stdin = 0, stdout = 1, stderr = 2} - for iostream, option in pairs(options) do - if option == M.subprocess.PIPE then + for iostream in pairs(stdiostreams) do + if options[iostream] == M.subprocess.PIPE then local piper, pipew = posix_unistd.pipe() if iostream == "stdin" then childfds[iostream] = piper @@ -223,13 +224,13 @@ function M.subprocess.popen(path, argt, options) return nil, errmsg, errnum elseif pid == 0 then local null = -1 - local stdiostreams = {stdin = 0, stdout = 1, stderr = 2} if M.contains(options, M.subprocess.DEVNULL) then -- only open, if there's anything to discard null = posix_fcntl.open('/dev/null', posix_fcntl.O_RDWR) end - for iostream, option in pairs(options) do + for iostream in pairs(stdiostreams) do + local option = options[iostream] if option == M.subprocess.DEVNULL then posix_unistd.dup2(null, stdiostreams[iostream]) elseif option == M.subprocess.PIPE then