From e347b69e95bafc7c2f76800a7198732294f76d00 Mon Sep 17 00:00:00 2001 From: Tobias Ulmer Date: Fri, 15 Nov 2013 13:12:14 +0100 Subject: [PATCH] Inline callcmd() in callcmd_pipe() in order to remove later Signed-off-by: Tobias Ulmer --- generic/e2lib.lua | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/generic/e2lib.lua b/generic/e2lib.lua index bc3847c..ee05542 100644 --- a/generic/e2lib.lua +++ b/generic/e2lib.lua @@ -1095,8 +1095,28 @@ function e2lib.callcmd_pipe(cmds, infile, outfile) end eio.fclose(errin) - rc = callcmd(input, output, errout, cmds[cmdidx]) - os.exit(rc) + + -- redirect stdin + io.stdin:close() + rc, re = eio.dup2(eio.fileno(input), eio.STDIN) + if not rc then + e2lib.abort(re) + end + -- redirect stdout + io.stdout:close() + rc, re = eio.dup2(eio.fileno(output), eio.STDOUT) + if not rc then + e2lib.abort(re) + end + -- redirect stderr + io.stderr:close() + rc, re = eio.dup2(eio.fileno(errout), eio.STDERR) + if not rc then + e2lib.abort(re) + end + -- run the command + rc = os.execute(cmds[cmdidx]) + os.exit(rc/256) end pids[pid] = cmdidx -- 2.39.5