X-Git-Url: http://git.rot13.org/?p=BackupPC.git;a=blobdiff_plain;f=bin%2FBackupPC_archive;h=6ab75ea682e6acbb648eb84bb02a05e6a5c7280f;hp=c61e5cfb36008837c8a18000293f91afc2c141be;hb=e951f787a66c5bd9e9955c3f657a5b44289c0fe1;hpb=2c14784ad71874ec850d189060fe63d6eb9eba95 diff --git a/bin/BackupPC_archive b/bin/BackupPC_archive index c61e5cf..6ab75ea 100644 --- a/bin/BackupPC_archive +++ b/bin/BackupPC_archive @@ -8,10 +8,10 @@ # Usage: BackupPC_archive # # AUTHOR -# Craig Barratt +# Josh Marshall # # COPYRIGHT -# Copyright (C) 2001-2003 Craig Barratt +# Copyright (C) 2001-2004 Craig Barratt # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -29,7 +29,7 @@ # #======================================================================== # -# Version 2.1.0_CVS, released 8 Feb 2004. +# Version 2.1.0, released 20 Jun 2004. # # See http://backuppc.sourceforge.net. # @@ -241,12 +241,18 @@ sub ArchiveCleanup if ( !$stat{xferOK} ) { # - # kill off the tranfer program, first nicely then forcefully + # Kill off the tranfer program, first nicely then forcefully. + # We use negative PIDs to make sure all processes in each + # group get the signal. # if ( @xferPid ) { - kill(2, @xferPid); + foreach my $pid ( @xferPid ) { + kill($bpc->sigName2num("INT"), -$pid); + } sleep(1); - kill(9, @xferPid); + foreach my $pid ( @xferPid ) { + kill($bpc->sigName2num("KILL"), -$pid); + } } } @@ -272,11 +278,7 @@ sub ArchiveCleanup # If the archive failed, clean up # if ( !$stat{xferOK} ) { - # - # wait a short while and see if the system is still alive - # $stat{hostError} = $stat{lastOutputLine} if ( $stat{hostError} eq "" ); - sleep(2); $stat{hostAbort} = 1; $ArchiveLOG->write(\"Archive failed: $stat{hostError}") if ( defined($ArchiveLOG) ); @@ -336,9 +338,9 @@ sub pidHandler # sub UserCommandRun { - my($type) = @_; + my($cmdType) = @_; - return if ( !defined($Conf{$type}) ); + return if ( !defined($Conf{$cmdType}) ); my $vars = { xfer => $xfer, client => $client, @@ -358,10 +360,11 @@ sub UserCommandRun XferLOG => $ArchiveLOG, stat => \%stat, xferOK => $stat{xferOK} || 0, - type => $type, + type => "archive", + cmdType => $cmdType, }; - my $cmd = $bpc->cmdVarSubstitute($Conf{$type}, $vars); - $ArchiveLOG->write(\"Executing $type: @$cmd\n"); + my $cmd = $bpc->cmdVarSubstitute($Conf{$cmdType}, $vars); + $ArchiveLOG->write(\"Executing $cmdType: @$cmd\n"); # # Run the user's command, dumping the stdout/stderr into the # Xfer log file. Also supply the optional $vars and %Conf in