Explorar el Código

fixed error reporting with popen/pclose

Wolfgang Ortmann hace 7 años
padre
commit
bbebd885e3
Se han modificado 3 ficheros con 14 adiciones y 8 borrados
  1. BIN
      bin/kind
  2. 8 2
      src/filetools.cpp
  3. 6 6
      src/kind.ag

BIN
bin/kind


+ 8 - 2
src/filetools.cpp

@@ -241,7 +241,13 @@ Strings localExec(const std::string& cmd,
           if (debug)
             std::cout << ">>" << input << "<<" << std::endl;
         }
-      rc = pclose(fd);
+
+      int st = pclose(fd);
+      if (WIFEXITED(st))
+        rc = WEXITSTATUS(st);
+      else
+        rc = 0;
+
       if (debug)
         std::cout << "    result code: " << rc << std::endl;
     }
@@ -256,7 +262,7 @@ Strings localExec(const std::string& cmd,
   if (log.is_open())
     {
       log << "--------------------------------------------------------" << std::endl;
-      log << "result code: " << rc << std::endl;
+      log << "pclose result: " << rc << std::endl;
     }
   return res;
 }

+ 6 - 6
src/kind.ag

@@ -259,7 +259,7 @@ Images findImages(const string& vaultpath, const KindConfig& conf, bool alsoInva
 }
 
 void listImageInfo(const string& vault,
-                   KindConfig conf /*Copy!*/ ,
+                   KindConfig conf /*Copy!*/,
                    const DateTime& imageTime,
                    const string& backupSet)
 {
@@ -337,7 +337,7 @@ void doBackup(const string& vault,
   if (!dryRun)
     {
       ofstream error(errorfile);
-      error << "failed" << endl;
+      error << "rsync not successfully completed" << endl;
       error.close();
     }
 
@@ -391,8 +391,8 @@ void doBackup(const string& vault,
       int rc;
       backupResult = localExec(rsyncCmd, rc, debug, imageFullName + "/rsync-log");
       if (rc == 0 ||  // "no error"
-          rc == 24 || // "vanished source files" (ignored)
-          rc == 6144) // workaround for wrong exit code ??!!
+          rc == 24 // "vanished source files" (ignored)
+         )
         {
           unlink(errorfile.c_str());
           double st = 0;
@@ -414,7 +414,7 @@ void doBackup(const string& vault,
 }
 
 bool backupVault(const string& vault,
-                 KindConfig conf /*Copy!*/ ,
+                 KindConfig conf /*Copy!*/,
                  const DateTime& imageTime,
                  bool fullImage,
                  const string& forcedBackupSet)
@@ -746,7 +746,7 @@ int main(int argc, char* argv[])
 
       if (listVault)
         {
-	  sort(vaults.begin(),vaults.end());
+          sort(vaults.begin(), vaults.end());
           for (string vault : vaults)
             {
               string vaultPath = findVault(vault);