s3:spoolssd Add spoolss own signal handlers
authorSimo Sorce <idra@samba.org>
Wed, 16 Jun 2010 17:03:32 +0000 (13:03 -0400)
committerGünther Deschner <gd@samba.org>
Tue, 29 Mar 2011 14:03:50 +0000 (16:03 +0200)
Signed-off-by: Günther Deschner <gd@samba.org>
source3/printing/spoolssd.c

index 1668bd886d84f2393203aba53e2d3f14b7b5a859..a7b64c9e61647dc52f7aea909ef9556cb81cd763 100644 (file)
@@ -49,6 +49,57 @@ static void smb_conf_updated(struct messaging_context *msg,
        spoolss_reopen_logs();
 }
 
+static void spoolss_sig_term_handler(struct tevent_context *ev,
+                                    struct tevent_signal *se,
+                                    int signum,
+                                    int count,
+                                    void *siginfo,
+                                    void *private_data)
+{
+       exit_server_cleanly("termination signal");
+}
+
+static void spoolss_setup_sig_term_handler(void)
+{
+       struct tevent_signal *se;
+
+       se = tevent_add_signal(server_event_context(),
+                              server_event_context(),
+                              SIGTERM, 0,
+                              spoolss_sig_term_handler,
+                              NULL);
+       if (!se) {
+               exit_server("failed to setup SIGTERM handler");
+       }
+}
+
+static void spoolss_sig_hup_handler(struct tevent_context *ev,
+                                   struct tevent_signal *se,
+                                   int signum,
+                                   int count,
+                                   void *siginfo,
+                                   void *private_data)
+{
+       change_to_root_user();
+       DEBUG(1,("Reloading printers after SIGHUP\n"));
+       reload_printers(server_messaging_context());
+       spoolss_reopen_logs();
+}
+
+static void spoolss_setup_sig_hup_handler(void)
+{
+       struct tevent_signal *se;
+
+       se = tevent_add_signal(server_event_context(),
+                              server_event_context(),
+                              SIGHUP, 0,
+                              spoolss_sig_hup_handler,
+                              NULL);
+       if (!se) {
+               exit_server("failed to setup SIGHUP handler");
+       }
+}
+
 void start_spoolssd(void)
 {
        pid_t pid;
@@ -83,8 +134,8 @@ void start_spoolssd(void)
 
        spoolss_reopen_logs();
 
-       smbd_setup_sig_term_handler();
-       smbd_setup_sig_hup_handler();
+       spoolss_setup_sig_term_handler();
+       spoolss_setup_sig_hup_handler();
 
        if (!serverid_register(procid_self(),
                                FLAG_MSG_GENERAL|FLAG_MSG_SMBD