Implement --reload.
authorAndre Noll <maan@systemlinux.org>
Sat, 26 Mar 2011 14:37:06 +0000 (15:37 +0100)
committerAndre Noll <maan@systemlinux.org>
Fri, 1 Jun 2012 15:31:36 +0000 (17:31 +0200)
This is literally the same as --kill, the only difference being that
SIGHUP rather than SIGTERM is sent.

dss.c
dss.ggo

diff --git a/dss.c b/dss.c
index 63f5f56..793e919 100644 (file)
--- a/dss.c
+++ b/dss.c
@@ -172,7 +172,9 @@ static void dump_dss_config(const char *msg)
        COMMAND(create) \
        COMMAND(prune) \
        COMMAND(run) \
-       COMMAND(kill)
+       COMMAND(kill) \
+       COMMAND(reload) \
+
 #define COMMAND(x) static int com_ ##x(void);
 COMMANDS
 #undef COMMAND
@@ -240,7 +242,7 @@ static char *get_config_file_name(void)
        return config_file;
 }
 
-static int com_kill(void)
+static int send_signal(int sig)
 {
        pid_t pid;
        char *config_file = get_config_file_name();
@@ -253,12 +255,22 @@ static int com_kill(void)
                dss_msg("%d\n", (int)pid);
                return 0;
        }
-       ret = kill(pid, SIGTERM);
+       ret = kill(pid, sig);
        if (ret < 0)
                return -ERRNO_TO_DSS_ERROR(errno);
        return 1;
 }
 
+static int com_kill(void)
+{
+       return send_signal(SIGTERM);
+}
+
+static int com_reload(void)
+{
+       return send_signal(SIGHUP);
+}
+
 static void dss_get_snapshot_list(struct snapshot_list *sl)
 {
        get_snapshot_list(sl, conf.unit_interval_arg, conf.num_intervals_arg);
diff --git a/dss.ggo b/dss.ggo
index c594f6e..38e8637 100644 (file)
--- a/dss.ggo
+++ b/dss.ggo
@@ -155,6 +155,15 @@ details="
        process is written to stdout, but no signal is sent.
 "
 
+groupoption "reload" -
+#~~~~~~~~~~~~~~~~~~~~~
+"force a running dss process to reload its config file"
+group="command"
+details="
+       This differs from --kill only in that SIGHUP rather than SIGTERM
+       is sent to the dss process.
+"
+
 ###############################
 section "Rsync-related options"
 ###############################