Make daemon listener exit w/code 0 on SIGTERM.
authorWayne Davison <wayned@samba.org>
Sat, 16 Jun 2012 17:30:46 +0000 (10:30 -0700)
committerWayne Davison <wayned@samba.org>
Sat, 16 Jun 2012 17:31:14 +0000 (10:31 -0700)
rsync.c

diff --git a/rsync.c b/rsync.c
index c42d55352e1917ec5052c20418e9eedba8bf8dae..93f6b9880df64841ddec3343714d989514b73394 100644 (file)
--- a/rsync.c
+++ b/rsync.c
@@ -35,6 +35,7 @@ extern int preserve_executability;
 extern int preserve_times;
 extern int am_root;
 extern int am_server;
+extern int am_daemon;
 extern int am_sender;
 extern int am_receiver;
 extern int am_generator;
@@ -599,7 +600,7 @@ int set_file_attrs(const char *fname, struct file_struct *file, stat_x *sxp,
        return updated;
 }
 
-RETSIGTYPE sig_int(UNUSED(int val))
+RETSIGTYPE sig_int(int sig_num)
 {
        /* KLUGE: if the user hits Ctrl-C while ssh is prompting
         * for a password, then our cleanup's sending of a SIGUSR1
@@ -610,6 +611,10 @@ RETSIGTYPE sig_int(UNUSED(int val))
         * not ssh waiting for a password, then this tiny delay
         * shouldn't hurt anything. */
        msleep(400);
+       /* If we're an rsync daemon listener (not a daemon server),
+        * we'll exit with status 0 if we received SIGTERM. */
+       if (am_daemon && !am_server && sig_num == SIGTERM)
+               exit_cleanup(0);
        exit_cleanup(RERR_SIGNAL);
 }