summaryrefslogtreecommitdiff
path: root/src/supervision
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2020-01-15 15:09:35 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2020-01-15 15:09:35 +0000
commite22ada794ba3ab78bd84036ca045ce748d8671e5 (patch)
tree194b8a0c681c8d52e4588c159ae684c574e0ae18 /src/supervision
parent597dc96fec06714019afe95487cd1065239b8049 (diff)
downloads6-e22ada794ba3ab78bd84036ca045ce748d8671e5.tar.xz
Restore console fd on s6-svscan exec
Diffstat (limited to 'src/supervision')
-rw-r--r--src/supervision/s6-svscan.c11
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() ;
}
{