* Several improvements to restore: cancel now reports the correct
[BackupPC.git] / bin / BackupPC_dump
index 8d27db3..928dc50 100755 (executable)
@@ -70,7 +70,7 @@
 #
 #========================================================================
 #
-# Version 2.0.0beta2, released 13 Apr 2003.
+# Version 2.0.0beta3, released 1 Jun 2003.
 #
 # See http://backuppc.sourceforge.net.
 #
@@ -83,6 +83,7 @@ use BackupPC::FileZIO;
 use BackupPC::Xfer::Smb;
 use BackupPC::Xfer::Tar;
 use BackupPC::Xfer::Rsync;
+use Socket;
 use File::Path;
 use Getopt::Std;
 
@@ -146,7 +147,8 @@ if ( $opts{d} ) {
     $Hosts = $bpc->HostInfoRead($client);
 }
 if ( !defined($Hosts->{$client}) ) {
-    print("Exiting because host $client does not exist in the hosts file\n");
+    print("Exiting because host $client does not exist in the hosts file\n")
+                           if ( $opts{v} );
     exit(1)
 }
 
@@ -445,12 +447,22 @@ for my $shareName ( @$ShareNames ) {
        # This xfer method outputs a tar format file, so we start a
        # BackupPC_tarExtract to extract the data.
        #
-       # Create a pipe to connect the Xfer method to BackupPC_tarExtract
+       # Create a socketpair to connect the Xfer method to BackupPC_tarExtract
        # WH is the write handle for writing, provided to the transport
-       # program, and RH is the other end of the pipe for reading,
+       # program, and RH is the other end of the socket for reading,
        # provided to BackupPC_tarExtract.
        #
-       pipe(RH, WH);
+        if ( socketpair(RH, WH, AF_UNIX, SOCK_STREAM, PF_UNSPEC) ) {
+           shutdown(RH, 1);    # no writing to this socket
+           shutdown(WH, 0);    # no reading from this socket
+           setsockopt(RH, SOL_SOCKET, SO_RCVBUF, 8 * 65536);
+           setsockopt(WH, SOL_SOCKET, SO_SNDBUF, 8 * 65536);
+       } else {
+           #
+           # Default to pipe() if socketpair() doesn't work.
+           #
+           pipe(RH, WH);
+       }
 
        #
        # fork a child for BackupPC_tarExtract.  TAR is a file handle
@@ -600,7 +612,7 @@ for my $shareName ( @$ShareNames ) {
                # the transfer.
                #
                if ( my $errMsg = CorrectHostCheck($hostIP, $host) ) {
-                   $stat{hostError} = $errMsg;
+                   $stat{hostError} = $errMsg if ( $stat{hostError} eq "" );
                    last SCAN;
                }
            }
@@ -807,7 +819,12 @@ sub catch_signal
     my $fileExt = $Conf{CompressLevel} > 0 ? ".z" : "";
 
     #
-    # Ignore signals in children
+    # Children quit quietly on ALRM
+    #
+    exit(1) if ( $Pid != $$ && $signame eq "ALRM" );
+
+    #
+    # Ignore other signals in children
     #
     return if ( $Pid != $$ );