]> git.e2factory.org Git - e2factory.git/commitdiff
Inline callcmd() in callcmd_pipe() in order to remove later
authorTobias Ulmer <tu@emlix.com>
Fri, 15 Nov 2013 12:12:14 +0000 (13:12 +0100)
committerTobias Ulmer <tu@emlix.com>
Wed, 16 Nov 2016 14:41:17 +0000 (15:41 +0100)
Signed-off-by: Tobias Ulmer <tu@emlix.com>
generic/e2lib.lua

index bc3847ce25cc481ca7193276d23143b9922203f6..ee055425f119043f1204dbe87a7403ec185db740 100644 (file)
@@ -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