]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
new feature: squid -k restart
authorwessels <>
Sat, 6 May 2006 05:33:21 +0000 (05:33 +0000)
committerwessels <>
Sat, 6 May 2006 05:33:21 +0000 (05:33 +0000)
It allows the built-in parent "watcher" process to automatically
and immediately restart Squid.

-k restart uses SIGTTIN.  It is almost the same as -k shutdown
except that it sets the exit status to 1 (instead of 0).  Since the
exit status is non-zero, the parent (watcher) will start squid again
immediately.

-k restart is not supported on systems that dont have SIGTTIN.

src/main.cc

index 8bc9f27799c08022ad6ba52e2fb3205459a5981d..eecea8eaf7412bff5509cb9495a66f729a183e6a 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: main.cc,v 1.418 2006/04/29 13:53:16 serassio Exp $
+ * $Id: main.cc,v 1.419 2006/05/05 23:33:21 wessels Exp $
  *
  * DEBUG: section 1     Startup and Main Loop
  * AUTHOR: Harvest Derived
@@ -76,6 +76,7 @@ static int malloc_debug_level = 0;
 static volatile int do_reconfigure = 0;
 static volatile int do_rotate = 0;
 static volatile int do_shutdown = 0;
+static volatile int shutdown_status = 0;
 
 static void mainRotate(void);
 static void mainReconfigure(void);
@@ -292,6 +293,14 @@ mainParseOptions(int argc, char *argv[])
                 opt_send_signal = SIGINT;
             else if (!strncmp(optarg, "kill", strlen(optarg)))
                 opt_send_signal = SIGKILL;
+
+#ifdef SIGTTIN
+
+            else if (!strncmp(optarg, "restart", strlen(optarg)))
+                opt_send_signal = SIGTTIN;      /* exit and restart by parent */
+
+#endif
+
             else if (!strncmp(optarg, "check", strlen(optarg)))
                 opt_send_signal = 0;   /* SIGNULL */
             else if (!strncmp(optarg, "parse", strlen(optarg)))
@@ -427,6 +436,12 @@ void
 shut_down(int sig)
 {
     do_shutdown = sig == SIGINT ? -1 : 1;
+#ifdef SIGTTIN
+
+    if (SIGTTIN == sig)
+        shutdown_status = 1;
+
+#endif
 #ifndef _SQUID_MSWIN_
 #ifdef KILL_PARENT_OPT
 
@@ -833,6 +848,12 @@ mainInitialize(void)
 
     squid_signal(SIGINT, shut_down, SA_NODEFER | SA_RESETHAND | SA_RESTART);
 
+#ifdef SIGTTIN
+
+    squid_signal(SIGTTIN, shut_down, SA_NODEFER | SA_RESETHAND | SA_RESTART);
+
+#endif
+
     memCheckInit();
 
     debug(1, 1) ("Ready to serve requests.\n");
@@ -1571,5 +1592,5 @@ SquidShutdown(void *unused)
     if (debug_log)
         fclose(debug_log);
 
-    exit(0);
+    exit(shutdown_status);
 }