From: Tobias Ulmer Date: Mon, 18 Feb 2019 18:32:46 +0000 (+0100) Subject: e2build: for interactive playground use, setup standard file descriptors X-Git-Tag: e2factory-2.3.18rc1~33 X-Git-Url: https://git.e2factory.org/?a=commitdiff_plain;h=2aa415272e6c9b7bd63b4300ecdd916bd6e0adcb;p=e2factory.git e2build: for interactive playground use, setup standard file descriptors Because we request a pty for signaling purposes, interactive use of the shell isn't possible. To enable interactive use, duplicate the standard descriptors of the parent and set them up in the child which will end up being bash. Signed-off-by: Tobias Ulmer --- diff --git a/local/e2build.lua b/local/e2build.lua index 8797b9f..e561f91 100644 --- a/local/e2build.lua +++ b/local/e2build.lua @@ -264,8 +264,21 @@ function e2build.build_process_class:_enter_playground(res, rbs) table.insert(cmd, "-c") table.insert(cmd, rbs:build_settings():command()) + -- The shell is for interactive use, but we still want a pty for terminating + -- e2-su via signal. + -- This means we have to save the standard file descriptors and re-dup2 them + -- in place after forkpty. + local fdctv = {} + for _,fd in ipairs({eio.STDIN, eio.STDOUT, eio.STDERR}) do + local fdnew, re = eio.dup(fd) + if not fdnew then + return false, e:cat(re) + end + table.insert(fdctv, { dup = fd, istype = "readfo", file = fdnew }) + end + e2tool.set_umask() - rc, re = e2lib.callcmd(cmd, nil, nil, nil, nil, true) + rc, re = e2lib.callcmd(cmd, fdctv, nil, nil, nil, true) if not rc then e2tool.reset_umask() return false, e:cat(re)