diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2020-01-15 15:09:35 +0000 |
---|---|---|
committer | Laurent Bercot <ska-skaware@skarnet.org> | 2020-01-15 15:09:35 +0000 |
commit | e22ada794ba3ab78bd84036ca045ce748d8671e5 (patch) | |
tree | 194b8a0c681c8d52e4588c159ae684c574e0ae18 /src | |
parent | 597dc96fec06714019afe95487cd1065239b8049 (diff) | |
download | s6-e22ada794ba3ab78bd84036ca045ce748d8671e5.tar.xz |
Restore console fd on s6-svscan exec
Diffstat (limited to 'src')
-rw-r--r-- | src/supervision/s6-svscan.c | 11 |
1 files changed, 11 insertions, 0 deletions
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() ; } { |