s6

Mirror/fork of https://skarnet.org/software/s6/
git clone https://ccx.te2000.cz/git/s6
Log | Files | Refs | README | LICENSE

commit e22ada794ba3ab78bd84036ca045ce748d8671e5
parent 597dc96fec06714019afe95487cd1065239b8049
Author: Laurent Bercot <ska-skaware@skarnet.org>
Date:   Wed, 15 Jan 2020 15:09:35 +0000

 Restore console fd on s6-svscan exec

Diffstat:
Msrc/supervision/s6-svscan.c | 11+++++++++++
1 file changed, 11 insertions(+), 0 deletions(-)

diff --git 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() ; } {