summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2011-12-13 09:04:20 +0100
committerStefan Metzmacher <metze@samba.org>2011-12-13 12:36:35 +0100
commit2bab5073bace651a8961400ca39e2329c4d04b65 (patch)
tree2a77fa054823729194be32bc8119b90e57faf54d
parent1738a61b846e39c6a09b16ca01a40f9890c16991 (diff)
downloadsamba-2bab5073bace651a8961400ca39e2329c4d04b65.tar.gz
samba-2bab5073bace651a8961400ca39e2329c4d04b65.tar.bz2
samba-2bab5073bace651a8961400ca39e2329c4d04b65.zip
s3:smbd/server: add parent specific SIGTERM and SIGHUP handlers
metze
-rw-r--r--source3/smbd/server.c48
1 files changed, 45 insertions, 3 deletions
diff --git a/source3/smbd/server.c b/source3/smbd/server.c
index 7985efc895..948fd7f359 100644
--- a/source3/smbd/server.c
+++ b/source3/smbd/server.c
@@ -834,6 +834,34 @@ static bool init_structs(void )
return True;
}
+static void smbd_parent_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 smbd_parent_sig_hup_handler(struct tevent_context *ev,
+ struct tevent_signal *se,
+ int signum,
+ int count,
+ void *siginfo,
+ void *private_data)
+{
+ struct smbd_parent_context *parent =
+ talloc_get_type_abort(private_data,
+ struct smbd_parent_context);
+
+ change_to_root_user();
+ DEBUG(1,("parent: Reloading services after SIGHUP\n"));
+ reload_services(parent->msg_ctx, -1, false);
+
+ printing_subsystem_update(parent->ev_ctx, parent->msg_ctx, true);
+}
+
/****************************************************************************
main program.
****************************************************************************/
@@ -884,6 +912,7 @@ extern void build_options(bool screen);
uint64_t unique_id;
struct tevent_context *ev_ctx;
struct messaging_context *msg_ctx;
+ struct tevent_signal *se;
/*
* Do this before any other talloc operation
@@ -1134,9 +1163,22 @@ extern void build_options(bool screen);
parent->ev_ctx = ev_ctx;
parent->msg_ctx = msg_ctx;
- smbd_setup_sig_term_handler();
- smbd_setup_sig_hup_handler(ev_ctx,
- msg_ctx);
+ se = tevent_add_signal(parent->ev_ctx,
+ parent,
+ SIGTERM, 0,
+ smbd_parent_sig_term_handler,
+ parent);
+ if (!se) {
+ exit_server("failed to setup SIGTERM handler");
+ }
+ se = tevent_add_signal(parent->ev_ctx,
+ parent,
+ SIGHUP, 0,
+ smbd_parent_sig_hup_handler,
+ parent);
+ if (!se) {
+ exit_server("failed to setup SIGHUP handler");
+ }
/* Setup all the TDB's - including CLEAR_IF_FIRST tdb's. */