summaryrefslogtreecommitdiffstats
path: root/src/util/server.c
diff options
context:
space:
mode:
authorJakub Hrozek <jhrozek@redhat.com>2010-02-24 18:58:15 +0100
committerStephen Gallagher <sgallagh@redhat.com>2010-03-08 13:42:46 -0500
commit71cd2f7ce705561d8d8f3cb7f385a57bedad1ef1 (patch)
tree3d8e723c7deedc04468e4e0a1a52b60c0d0b302e /src/util/server.c
parentbc7d61995ed04de885cb8e4bf4c5f2dcbc780649 (diff)
downloadsssd-71cd2f7ce705561d8d8f3cb7f385a57bedad1ef1.tar.gz
sssd-71cd2f7ce705561d8d8f3cb7f385a57bedad1ef1.tar.xz
sssd-71cd2f7ce705561d8d8f3cb7f385a57bedad1ef1.zip
Reopen logs when SIGHUP is caught
Upon receiving SIGHUP, the monitor signals all services to reopen their debug logs. It is also possible to signal individual services to reopen their particular files. Fixes: #332
Diffstat (limited to 'src/util/server.c')
-rw-r--r--src/util/server.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/util/server.c b/src/util/server.c
index 226e16e25..a0ec2a265 100644
--- a/src/util/server.c
+++ b/src/util/server.c
@@ -284,6 +284,17 @@ int die_if_parent_died(void)
return EOK;
}
+static void te_server_hup(struct tevent_context *ev,
+ struct tevent_signal *se,
+ int signum,
+ int count,
+ void *siginfo,
+ void *private_data)
+{
+ DEBUG(1, ("Received SIGHUP. Rotating logfiles.\n"));
+ rotate_debug_files();
+}
+
int server_setup(const char *name, int flags,
const char *conf_entry,
struct main_context **main_ctx)
@@ -295,6 +306,7 @@ int server_setup(const char *name, int flags,
int ret = EOK;
bool dt;
bool dl;
+ struct tevent_signal *tes;
debug_prg_name = strdup(name);
if (!debug_prg_name) {
@@ -391,6 +403,13 @@ int server_setup(const char *name, int flags,
}
if (dl) debug_to_file = 1;
+ /* before opening the log file set up log rotation */
+ tes = tevent_add_signal(ctx->event_ctx, ctx, SIGHUP, 0,
+ te_server_hup, NULL);
+ if (tes == NULL) {
+ return EIO;
+ }
+
/* open log file if told so */
if (debug_to_file) {
ret = open_debug_file();