summaryrefslogtreecommitdiff
path: root/source4/smbd
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2017-04-07 15:31:57 -0700
committerRalph Boehme <slow@samba.org>2017-04-08 12:30:08 +0200
commitd354be9e078730505462623225295e675d73fd86 (patch)
treec44c59c7ba79609d2f6be69b22cb87b71367f0cd /source4/smbd
parent513eb8b8d397a9d6a5b7f029590b2e7dc0c1b743 (diff)
downloadsamba-d354be9e078730505462623225295e675d73fd86.tar.gz
s4: process_standard: Add tevent SIGHUP signal handler to standard_accept_connection() and standard_new_task().
This makes us independent of parent SIGHUP signal handling. Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
Diffstat (limited to 'source4/smbd')
-rw-r--r--source4/smbd/process_standard.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/source4/smbd/process_standard.c b/source4/smbd/process_standard.c
index 39edbfb8f43..776e497e987 100644
--- a/source4/smbd/process_standard.c
+++ b/source4/smbd/process_standard.c
@@ -29,6 +29,7 @@
#include "param/param.h"
#include "ldb_wrap.h"
#include "lib/messaging/messaging.h"
+#include "lib/util/debug.h"
struct standard_child_state {
const char *name;
@@ -58,6 +59,14 @@ static void standard_model_init(void)
}
}
+static void sighup_signal_handler(struct tevent_context *ev,
+ struct tevent_signal *se,
+ int signum, int count, void *siginfo,
+ void *private_data)
+{
+ debug_schedule_reopen_logs();
+}
+
/*
handle EOF on the parent-to-all-children pipe in the child
*/
@@ -213,6 +222,7 @@ static void standard_accept_connection(struct tevent_context *ev,
struct socket_address *c, *s;
struct standard_child_state *state;
struct tevent_fd *fde = NULL;
+ struct tevent_signal *se = NULL;
state = setup_standard_child_pipe(ev, NULL);
if (state == NULL) {
@@ -290,6 +300,16 @@ static void standard_accept_connection(struct tevent_context *ev,
child_pipe[1] = -1;
}
+ se = tevent_add_signal(ev,
+ ev,
+ SIGHUP,
+ 0,
+ sighup_signal_handler,
+ NULL);
+ if (se == NULL) {
+ smb_panic("Failed to add SIGHUP handler after fork");
+ }
+
/* setup the process title */
c = socket_get_peer_addr(sock2, ev);
s = socket_get_my_addr(sock2, ev);
@@ -325,6 +345,7 @@ static void standard_new_task(struct tevent_context *ev,
NTSTATUS status;
struct standard_child_state *state;
struct tevent_fd *fde = NULL;
+ struct tevent_signal *se = NULL;
state = setup_standard_child_pipe(ev, service_name);
if (state == NULL) {
@@ -377,6 +398,16 @@ static void standard_new_task(struct tevent_context *ev,
child_pipe[1] = -1;
}
+ se = tevent_add_signal(ev,
+ ev,
+ SIGHUP,
+ 0,
+ sighup_signal_handler,
+ NULL);
+ if (se == NULL) {
+ smb_panic("Failed to add SIGHUP handler after fork");
+ }
+
setproctitle("task %s server_id[%d]", service_name, (int)pid);
/* setup this new task. Cluster ID is PID based for this process model */