If dss is about to die because it received SIGINT or SIGTERM, we first
restart the rsync process by sending SIGCONT, then send SIGTERM to
both the rsync and the rm process to get rid of any child processes.
This works fine, but there are other fatal errors for which we miss
to clean up as thoroughly, most importantly if there is not enough
free disk space for a single snapshot.
This patch moves the signal-related cleanup part to the new function
kill_children(), and changes handle_signal() and com_run() to call
this function right before the exit hook is invoked.
return change_to_dest_dir();
}
+static void kill_children(void)
+{
+ restart_create_process();
+ dss_kill(create_pid, SIGTERM, NULL);
+ dss_kill(remove_pid, SIGTERM, NULL);
+}
+
static int handle_signal(void)
{
int sig, ret = next_signal();
switch (sig) {
case SIGINT:
case SIGTERM:
- restart_create_process();
- dss_kill(create_pid, SIGTERM, NULL);
- dss_kill(remove_pid, SIGTERM, NULL);
+ kill_children();
ret = -E_SIGNAL;
break;
case SIGHUP:
ret = select_loop();
if (ret >= 0) /* impossible */
ret = -E_BUG;
+ kill_children();
exit_hook(ret);
return ret;
}