]> git.e2factory.org Git - e2factory.git/commitdiff
e2lib: extend callcmd()
authorTobias Ulmer <tu@emlix.com>
Mon, 2 Jan 2017 19:21:48 +0000 (20:21 +0100)
committerTobias Ulmer <tu@emlix.com>
Mon, 2 Jan 2017 19:21:48 +0000 (20:21 +0100)
Signed-off-by: Tobias Ulmer <tu@emlix.com>
generic/e2lib.lua

index 80ac0c1670c5b0142bb9f84431a53c39242acac3..3db930cf7cc6ac8a54115e985fc8c4533648ca57 100644 (file)
@@ -1110,7 +1110,7 @@ end
 -- "readfo", the following field are expected in addition to ones in fdct.
 -- The file object is used as an input to the child.
 -- @table fdct_readfo
--- @field file Readable file object.
+-- @field file Readable file object or file descriptor (number).
 -- @see fdct
 
 --- File descriptor configuration table - writefunc. This is an extension to
@@ -1200,7 +1200,13 @@ function e2lib.callcmd(argv, fdctv, workdir, envdict, nowait)
                     end
                 end
             elseif fdct.istype == "readfo" then
-                rc, re = eio.dup2(eio.fileno(fdct.file), fdct.dup)
+                local fd
+                if type(fdct.file) == "number" then
+                    fd = fdct.file
+                else
+                    fd = eio.fileno(fdct.file)
+                end
+                rc, re = eio.dup2(fd, fdct.dup)
                 if not rc then
                     e2lib.abort(re)
                 end