Kill all dump processes
authorJamie Cameron <jcameron@webmin.com>
Mon, 27 Apr 2009 21:34:44 +0000 (21:34 +0000)
committerJamie Cameron <jcameron@webmin.com>
Mon, 27 Apr 2009 21:34:44 +0000 (21:34 +0000)
fsdump/CHANGELOG
fsdump/kill.cgi
fsdump/lang/en
fsdump/log_parser.pl

index 2104cd3..91c822d 100644 (file)
@@ -37,3 +37,5 @@ Added checkboxes to control if failure of the pre and post-backup commands cause
 Prevent non-level-0 backups and updating of the /etc/dumpdates file for backups of directories that are not filesystem mount points, as this isn't supported by the <tt>dump</tt> command.
 ---- Changes since 1.440 ----
 Fixed a bug that prevented backups of directories with spaces in their names from working properly on Linux.
+---- Changes since 1.480 ----
+When terminating a running backup, all sub-processes such as tar and dump commands are killed too.
index 5b301b2..2993d35 100755 (executable)
@@ -10,11 +10,29 @@ require './fsdump-lib.pl';
 @procs = &proc::list_processes();
 @running = &running_dumps(\@procs);
 
+# Find the job
 ($job) = grep { $_->{'id'} eq $in{'id'} &&
                $_->{'pid'} == $in{'pid'} } @running;
 $job || &error($text{'kill_egone'});
 &can_edit_dir($job) || &error($text{'kill_ecannot'});
 
-kill('TERM', $job->{'pid'});
+# Find all sub-processes
+@killprocs = ( $job->{'pid'}, &find_subprocesses($job->{'pid'}) );
+&kill_logged('TERM', @killprocs);
+sleep(1);
+&kill_logged('KILL', @killprocs);
+&webmin_log("kill", undef, $job->{'id'}, $job);
 &redirect("");
 
+sub find_subprocesses
+{
+local ($pid) = @_;
+local @rv;
+foreach my $p (@procs) {
+       if ($p->{'ppid'} && $p->{'ppid'} eq $pid) {
+               push(@rv, $p->{'pid'}, &find_subprocesses($p->{'pid'}));
+               }
+       }
+return @rv;
+}
+
index a810d1d..1e236b4 100644 (file)
@@ -195,6 +195,7 @@ log_delete=Deleted backup config for $1
 log_backup=Backed up $1 to $2
 log_bgbackup=Started backup of $1 to $2
 log_restore=Restored backup from $1
+log_kill=Terminated backup for $1
 
 kill_err=Failed to terminate backup
 kill_egone=No longer running!
index cb15e0f..0bdc2c6 100644 (file)
@@ -8,7 +8,8 @@ do 'fsdump-lib.pl';
 sub parse_webmin_log
 {
 local ($user, $script, $action, $type, $object, $p) = @_;
-if ($action eq 'create' || $action eq 'modify' || $action eq 'delete') {
+if ($action eq 'create' || $action eq 'modify' ||
+    $action eq 'delete' || $action eq 'kill') {
        return &text("log_$action", "<tt>".&html_escape($p->{'dir'})."</tt>");
        }
 elsif ($action eq 'backup' || $action eq 'bgbackup') {