From ef2e27cbb10ab5aa23fd86d4e228c6b4d7fafe3c Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Wed, 16 Jun 2010 13:03:32 -0400 Subject: [PATCH] s3:spoolssd Add spoolss own signal handlers MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Günther Deschner (cherry picked from commit 0c130105f5b70803daf784bd9a3c86ed34295338) --- source3/printing/spoolssd.c | 55 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 53 insertions(+), 2 deletions(-) diff --git a/source3/printing/spoolssd.c b/source3/printing/spoolssd.c index 1668bd886d8..a7b64c9e616 100644 --- a/source3/printing/spoolssd.c +++ b/source3/printing/spoolssd.c @@ -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 -- 2.11.4.GIT