about summary refs log tree commit diff
path: root/src/daemontools-extras
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2021-12-24 08:31:27 +0000
committerLaurent Bercot <ska@appnovation.com>2021-12-24 08:31:27 +0000
commit61295482f0de9379ce428194f016f48cf9668b6a (patch)
tree3a1f4b702c216fdab56e6884d2b0e42eae5762ea /src/daemontools-extras
parent3962885e117e92a9b01d3a9d45895602115e725f (diff)
downloads6-61295482f0de9379ce428194f016f48cf9668b6a.tar.gz
s6-61295482f0de9379ce428194f016f48cf9668b6a.tar.xz
s6-61295482f0de9379ce428194f016f48cf9668b6a.zip
s6-log: restart event loop when closing stdin on signal
Signed-off-by: Laurent Bercot <ska@appnovation.com>
Diffstat (limited to 'src/daemontools-extras')
-rw-r--r--src/daemontools-extras/s6-log.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/daemontools-extras/s6-log.c b/src/daemontools-extras/s6-log.c
index 60de6b3..5a7ce4d 100644
--- a/src/daemontools-extras/s6-log.c
+++ b/src/daemontools-extras/s6-log.c
@@ -1115,14 +1115,15 @@ static inline void processor_died (logdir_t *ldp, int wstat)
   }
 }
 
-static inline void handle_signals (void)
+static inline int handle_signals (void)
 {
+  int e = 0 ;
   for (;;)
   {
     switch (selfpipe_read())
     {
       case -1 : strerr_diefu1sys(111, "selfpipe_read") ;
-      case 0 : return ;
+      case 0 : return e ;
       case SIGALRM :
       {
         unsigned int i = 0 ;
@@ -1138,7 +1139,7 @@ static inline void handle_signals (void)
         if (flagprotect) break ;
       case SIGHUP :
         handle_stdin = &last_stdin ;
-        if (!indata.len) prepare_to_exit() ;
+        if (!indata.len) { prepare_to_exit() ; e = 1 ; }
         break ;
       case SIGCHLD :
       {
@@ -1277,8 +1278,7 @@ int main (int argc, char const *const *argv)
       if (r < 0) strerr_diefu1sys(111, "iopause") ;
       else if (!r) continue ;
 
-      if (x[0].revents & IOPAUSE_READ) handle_signals() ;
-      else if (x[0].revents & IOPAUSE_EXCEPT) strerr_dief1sys(111, "trouble with selfpipe") ;
+      if (x[0].revents & (IOPAUSE_READ | IOPAUSE_EXCEPT) && handle_signals()) continue ;
 
       if (xindex1 && x[xindex1].revents)
       {