Index: trunk/ippToPsps/src/ippToPsps.c
===================================================================
--- trunk/ippToPsps/src/ippToPsps.c	(revision 27683)
+++ trunk/ippToPsps/src/ippToPsps.c	(revision 27684)
@@ -18,31 +18,35 @@
 #include "ippToPsps.h"
 
-extern bool ippToPsps_batchInit(IppToPsps *data);
-extern bool ippToPsps_batchDetection(IppToPsps *data);
-extern bool ippToPsps_batchStack(IppToPsps *data);
-extern bool ippToPsps_batchDifference(IppToPsps *data);
+extern int ippToPsps_batchInit(IppToPsps *data);
+extern int ippToPsps_batchDetection(IppToPsps *data);
+extern int ippToPsps_batchStack(IppToPsps *data);
+extern int ippToPsps_batchDifference(IppToPsps *data);
 
 // Destructor
 static void ippToPsps_Destructor(IppToPsps* this) {
 
-    // if unsuccessful, then delete FITS file
-    if (!this->success) {
-
-        psError(PS_ERR_UNKNOWN, false, "Failed, so deleting %s", this->fitsOutPath);
-
-        // if process failed, we need to delete that FITS file
-        if (remove(this->fitsOutPath) == -1) {
-
-            psError(PS_ERR_UNKNOWN, false, "Unable to delete %s", this->fitsOutPath);
-        }
-    }
-    // ...otherwise, close file
-    else {
-
-        int status = 0;
-        if (fits_close_file(this->fitsOut, &status)) {
-
-            psError(PS_ERR_IO, false, "Unable to close FITS file %s", this->fitsOutPath);
-            fits_report_error(stderr, status);
+    // if we created an output file...
+    if (this->fitsOut) {
+
+        // if unsuccessful, then delete FITS file
+        if (this->exitCode != PS_EXIT_SUCCESS) {
+
+            psError(PS_ERR_UNKNOWN, false, "Failed, so deleting %s", this->fitsOutPath);
+
+            // if process failed, we need to delete that FITS file
+            if (remove(this->fitsOutPath) == -1) {
+
+                psError(PS_ERR_UNKNOWN, false, "Unable to delete %s", this->fitsOutPath);
+            }
+        }
+        // ...otherwise, close file
+        else {
+
+            int status = 0;
+            if (fits_close_file(this->fitsOut, &status)) {
+
+                psError(PS_ERR_IO, false, "Unable to close FITS file %s", this->fitsOutPath);
+                fits_report_error(stderr, status);
+            }
         }
     }
@@ -77,5 +81,5 @@
 
         psError(PS_ERR_UNKNOWN, false, "Unable to open file at %s", this->fitsInPath);
-        return NULL;
+        return false;
     }
 
@@ -188,28 +192,31 @@
 
 // Runs the requested process
-static bool ippToPsps_run(IppToPsps *this) {
-
-    // which product?
-    switch(this->product) {
-
-        case PRODUCT_INIT:
-            this->success = ippToPsps_batchInit(this);
-            break;
-        case PRODUCT_DETECTION:
-            this->success = ippToPsps_batchDetection(this);
-            break;
-        case PRODUCT_STACK:
-            this->success = ippToPsps_batchStack(this);
-            break;
-        case PRODUCT_DIFFERENCE:
-            this->success = ippToPsps_batchDifference(this);
-            break;
-        default:
-            psError(PS_ERR_UNKNOWN, false, "Unable to run for this product type (%d)", this->product);
-            this->success = false;
-            break;
-    }
-
-    return this->success;
+static int ippToPsps_run(IppToPsps *this) {
+
+    if(this->exitCode == PS_EXIT_SUCCESS) {
+
+        // which product?
+        switch(this->product) {
+
+            case PRODUCT_INIT:
+                this->exitCode = ippToPsps_batchInit(this);
+                break;
+            case PRODUCT_DETECTION:
+                this->exitCode = ippToPsps_batchDetection(this);
+                break;
+            case PRODUCT_STACK:
+                this->exitCode = ippToPsps_batchStack(this);
+                break;
+            case PRODUCT_DIFFERENCE:
+                this->exitCode = ippToPsps_batchDifference(this);
+                break;
+            default:
+                psError(PS_ERR_UNKNOWN, false, "Unable to run for this product type (%d)", this->product);
+                this->exitCode = false;
+                break;
+        }
+    }
+
+    return this->exitCode;
 }
 
@@ -236,5 +243,5 @@
     this->dvoConfig = dvoConfigRead(argc, argv);
     this->pmconfig = pmConfigRead(argc, argv, NULL);
-    this->success = false;
+    this->exitCode = PS_EXIT_SUCCESS;
     this->run = ippToPsps_run;
 
@@ -242,5 +249,6 @@
 
         psError(PS_ERR_UNKNOWN, false, "Unable to read configuration.");
-        return NULL;
+        this->exitCode = PS_EXIT_CONFIG_ERROR;
+        return this;
     }
 
@@ -248,8 +256,13 @@
 
         psFree(this);
-        return NULL;
-    }
-
-    if (this->product != PRODUCT_INIT && !ippToPsps_readInputFilePaths(this)) return NULL;
+        this->exitCode = PS_EXIT_CONFIG_ERROR;
+        return this;
+    }
+
+    if (this->product != PRODUCT_INIT && !ippToPsps_readInputFilePaths(this)) {
+
+        this->exitCode = PS_EXIT_DATA_ERROR;
+        return this;
+    }
 
     if (this->product == PRODUCT_INIT)
@@ -272,9 +285,14 @@
         fits_report_error(stderr, status);
         psError(PS_ERR_IO, false, "Unable to create file at: '%s'", this->fitsOutPath);
-        return NULL;
+        this->exitCode = PS_EXIT_SYS_ERROR;
+        return this;
     }
 
     this->config = ippToPspsConfig_Constructor(this->configsDir);
-    if (this->config == NULL) return NULL;
+    if (this->config == NULL) {
+
+        this->exitCode = PS_EXIT_CONFIG_ERROR;
+        return this;
+    }
 
     // ready results file, if necessary
Index: trunk/ippToPsps/src/ippToPsps.h
===================================================================
--- trunk/ippToPsps/src/ippToPsps.h	(revision 27683)
+++ trunk/ippToPsps/src/ippToPsps.h	(revision 27684)
@@ -34,7 +34,7 @@
     dvoConfig* dvoConfig;      // dvo database
     IppToPspsConfig* config;   // config structure
-    bool success;              // overall success/failure
+    int exitCode;              // ps exit code
 
-    bool (*run)();
+    int (*run)();
 
 } IppToPsps;
Index: trunk/ippToPsps/src/main.c
===================================================================
--- trunk/ippToPsps/src/main.c	(revision 27683)
+++ trunk/ippToPsps/src/main.c	(revision 27684)
@@ -18,20 +18,17 @@
     ippToPsps_VersionPrint();
 
-    int ret = PS_EXIT_SUCCESS;
+    int exitCode;
 
     // create ippToPsps
     IppToPsps *ippToPsps = ippToPsps_Constructor(&argc, argv);
-
-    if (!ippToPsps) ret = PS_EXIT_CONFIG_ERROR;
-    else {
-
-        if (!ippToPsps->run(ippToPsps)) ret = PS_EXIT_DATA_ERROR;
-        psFree(ippToPsps);
-    }
+    ippToPsps->run(ippToPsps);
+    exitCode = ippToPsps->exitCode;
+    psFree(ippToPsps);
 
     double secs = psTimerMark("ippToPsps");
 
-    psLogMsg("ippToPsps", 3, "ippToPsps completed %ssuccessfully in %.1f %s\n", 
-            (ret == PS_EXIT_SUCCESS) ? "" : "un", 
+    psLogMsg("ippToPsps", 3, "ippToPsps completed %ssuccessfully, with exit code %d, in %.1f %s\n", 
+            (exitCode == PS_EXIT_SUCCESS) ? "" : "un",
+            exitCode,
             (secs<60.0) ? secs : (secs/60.0),
             (secs<60.0) ? "sec(s)" : "min(s)");
@@ -41,4 +38,4 @@
     psLibFinalize();
 
-    return ret;
+    return exitCode;
 }
