From e22ada794ba3ab78bd84036ca045ce748d8671e5 Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Wed, 15 Jan 2020 15:09:35 +0000 Subject: Restore console fd on s6-svscan exec --- src/supervision/s6-svscan.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/supervision') diff --git a/src/supervision/s6-svscan.c b/src/supervision/s6-svscan.c index c818498..ebf7594 100644 --- a/src/supervision/s6-svscan.c +++ b/src/supervision/s6-svscan.c @@ -55,6 +55,15 @@ static unsigned int wantkill = 0 ; static int cont = 1 ; static unsigned int consoleholder = 0 ; +static void restore_console (void) +{ + if (consoleholder) + { + fd_move(2, consoleholder) ; + if (fd_copy(1, 2) < 0) strerr_warnwu1sys("restore stdout") ; + } +} + static void panicnosp (char const *) gccattr_noreturn ; static void panicnosp (char const *errmsg) { @@ -71,6 +80,7 @@ static void panic (char const *errmsg) { int e = errno ; selfpipe_finish() ; + restore_console() ; errno = e ; panicnosp(errmsg) ; } @@ -565,6 +575,7 @@ int main (int argc, char const *const *argv) selfpipe_finish() ; killthem() ; + restore_console() ; reap() ; } { -- cgit v1.2.3