From: Tobias Ulmer Date: Fri, 15 Nov 2013 12:12:14 +0000 (+0100) Subject: Inline callcmd() in callcmd_pipe() in order to remove later X-Git-Tag: e2factory-2.3.15rc1~382 X-Git-Url: https://git.e2factory.org/?a=commitdiff_plain;h=e347b69e95bafc7c2f76800a7198732294f76d00;p=e2factory.git Inline callcmd() in callcmd_pipe() in order to remove later Signed-off-by: Tobias Ulmer --- 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