about summary refs log tree commit diff
path: root/src/supervision
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2022-06-28 10:12:52 +0000
committerLaurent Bercot <ska@appnovation.com>2022-06-28 10:12:52 +0000
commit19caa8b70a411074168ff5316b96cc3d686a9e25 (patch)
treeb55d467d31443b029e740feb640a095f2f228be1 /src/supervision
parent89b2bc9af553366c4092438b614dfa1b6b577c18 (diff)
downloads6-19caa8b70a411074168ff5316b96cc3d686a9e25.tar.gz
s6-19caa8b70a411074168ff5316b96cc3d686a9e25.tar.xz
s6-19caa8b70a411074168ff5316b96cc3d686a9e25.zip
s6-svscan: treat s6-svscan-log as a logger for s6-svscanctl purposes
Signed-off-by: Laurent Bercot <ska@appnovation.com>
Diffstat (limited to 'src/supervision')
-rw-r--r--src/supervision/s6-svscan.c53
1 files changed, 31 insertions, 22 deletions
diff --git a/src/supervision/s6-svscan.c b/src/supervision/s6-svscan.c
index ee0b013..740df49 100644
--- a/src/supervision/s6-svscan.c
+++ b/src/supervision/s6-svscan.c
@@ -47,6 +47,7 @@ struct svinfo_s
   int p[2] ;
   unsigned int flagactive : 1 ;
   unsigned int flaglog : 1 ;
+  unsigned int flagspecial : 1 ;
 } ;
 
 static struct svinfo_s *services ;
@@ -98,7 +99,7 @@ static void killthem (void)
   {
     if (!(wantkill & 1) && services[i].flagactive) continue ;
     if (services[i].pid[0])
-      kill(services[i].pid[0], (wantkill & 2) ? SIGTERM : SIGHUP) ;
+      kill(services[i].pid[0], (wantkill & (2 << services[i].flagspecial)) ? SIGTERM : SIGHUP) ;
     if (services[i].flaglog && services[i].pid[1])
       kill(services[i].pid[1], (wantkill & 4) ? SIGTERM : SIGHUP) ;
   }
@@ -330,10 +331,9 @@ static void trystart (unsigned int i, char const *name, int islog)
       if (services[i].flaglog)
         if (fd_move(!islog, services[i].p[!islog]) == -1)
           strerr_diefu2sys(111, "set fds for ", name) ;
-      if (consoleholder >= 0
-       && !strcmp(name, SPECIAL_LOGGER_SERVICE)
+      if (consoleholder >= 0 && services[i].flagspecial
        && fd_move(2, consoleholder) < 0)  /* autoclears coe */
-         strerr_diefu1sys(111, "restore console fd for service " SPECIAL_LOGGER_SERVICE) ;
+         strerr_diefu2sys(111, "restore console fd for service ", name) ;
       xexec_a(S6_BINPREFIX "s6-supervise", cargv) ;
     }
   }
@@ -380,29 +380,38 @@ static inline void check (char const *name)
     }
     else
     {
-      struct stat su ;
-      char tmp[namelen + 5] ;
-      memcpy(tmp, name, namelen) ;
-      memcpy(tmp + namelen, "/log", 5) ;
-      if (stat(tmp, &su) < 0)
-        if (errno == ENOENT) services[i].flaglog = 0 ;
-        else
-        {
-          strerr_warnwu2sys("stat ", tmp) ;
-          retrydirlater() ;
-          return ;
-        }
-      else if (!S_ISDIR(su.st_mode))
+      if (!strcmp(name, SPECIAL_LOGGER_SERVICE))
+      {
+        services[i].flagspecial = 1 ;
         services[i].flaglog = 0 ;
+      }
       else
       {
-        if (pipecoe(services[i].p) < 0)
+        struct stat su ;
+        char tmp[namelen + 5] ;
+        services[i].flagspecial = 0 ;
+        memcpy(tmp, name, namelen) ;
+        memcpy(tmp + namelen, "/log", 5) ;
+        if (stat(tmp, &su) < 0)
+          if (errno == ENOENT) services[i].flaglog = 0 ;
+          else
+          {
+            strerr_warnwu2sys("stat ", tmp) ;
+            retrydirlater() ;
+            return ;
+          }
+        else if (!S_ISDIR(su.st_mode))
+          services[i].flaglog = 0 ;
+        else
         {
-          strerr_warnwu1sys("pipecoe") ;
-          retrydirlater() ;
-          return ;
+          if (pipecoe(services[i].p) < 0)
+          {
+            strerr_warnwu1sys("pipecoe") ;
+            retrydirlater() ;
+            return ;
+          }
+          services[i].flaglog = 1 ;
         }
-        services[i].flaglog = 1 ;
       }
       services[i].ino = st.st_ino ;
       services[i].dev = st.st_dev ;