From 2aa415272e6c9b7bd63b4300ecdd916bd6e0adcb Mon Sep 17 00:00:00 2001 From: Tobias Ulmer Date: Mon, 18 Feb 2019 19:32:46 +0100 Subject: [PATCH] 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 --- local/e2build.lua | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) 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) -- 2.39.5