Index: /trunk/ippTools/src/dettool.c
===================================================================
--- /trunk/ippTools/src/dettool.c	(revision 11854)
+++ /trunk/ippTools/src/dettool.c	(revision 11855)
@@ -95,4 +95,8 @@
 
     pxConfig *config = dettoolConfig(NULL, argc, argv);
+    if (!config) {
+        psError(PXTOOLS_ERR_CONFIG, false, "failed to configure");
+        goto FAIL;
+    }
 
     switch (config->mode) {
@@ -147,4 +151,5 @@
 FAIL:
     psErrorStackPrint(stderr, "\n");
+    int exit_status = pxerrorGetExitStatus();
 
     psFree(config);
@@ -152,5 +157,5 @@
     psLibFinalize();
 
-    exit(EXIT_FAILURE);
+    exit(exit_status);
 }
 
Index: /trunk/ippTools/src/dettoolConfig.c
===================================================================
--- /trunk/ippTools/src/dettoolConfig.c	(revision 11854)
+++ /trunk/ippTools/src/dettoolConfig.c	(revision 11855)
@@ -27,5 +27,4 @@
 #include "dettool.h"
 
-// this function can not fail -- exits on error
 pxConfig *dettoolConfig(pxConfig *config, int argc, char **argv) {
     if (!config) {
@@ -39,5 +38,6 @@
     if (!config->modules) {
         psError(PS_ERR_UNKNOWN, false, "Can't find site configuration");
-        goto FAIL;
+        psFree(config);
+        return NULL;
     }
 
@@ -785,5 +785,6 @@
             psFree(argset); \
             psFree(argSets); \
-            goto FAIL; \
+            psFree(config); \
+            return NULL; \
         } \
         config->mode = modeval; \
@@ -873,5 +874,6 @@
         psFree(iter);
         psFree(argSets);
-        goto FAIL;
+        psFree(config);
+        return NULL;
     }
 
@@ -886,5 +888,6 @@
         if (!psMetadataAddStr(config->where, PS_LIST_TAIL, #name, 0, "==", str)) {\
             psError(PS_ERR_UNKNOWN, false, "failed to add item " #name); \
-            goto FAIL; \
+            psFree(config); \
+            return NULL; \
         } \
     } \
@@ -901,5 +904,6 @@
             if (!psMetadataAddS32(config->where, PS_LIST_TAIL, "iteration", 0, "==", n)) {
                 psError(PS_ERR_UNKNOWN, false, "failed to add item iteration");
-                goto FAIL;
+                psFree(config);
+                return NULL;
             }
         }
@@ -915,5 +919,6 @@
             if (!psMetadataAddStr(config->where, PS_LIST_TAIL, "camera", 0, "==", str)) {
                 psError(PS_ERR_UNKNOWN, false, "failed to add item camera");
-                goto FAIL;
+                psFree(config);
+                return NULL;
             }
         }
@@ -927,5 +932,6 @@
             if (!psMetadataAddS32(config->where, PS_LIST_TAIL, "imfiles", 0, "==", n)) {
                 psError(PS_ERR_UNKNOWN, false, "failed to add item imfiles");
-                goto FAIL;
+                psFree(config);
+                return NULL;
             }
         }
@@ -939,5 +945,6 @@
             if (!psMetadataAddS32(config->where, PS_LIST_TAIL, "p1_version", 0, "==", n)) {
                 psError(PS_ERR_UNKNOWN, false, "failed to add item p1_version");
-                goto FAIL;
+                psFree(config);
+                return NULL;
             }
         }
@@ -951,5 +958,6 @@
             if (!psMetadataAddBool(config->where, PS_LIST_TAIL, "accept", 0, "==", !boolean)) {
                 psError(PS_ERR_UNKNOWN, false, "failed to add item reject");
-                goto FAIL;
+                psFree(config);
+                return NULL;
             }
         }
@@ -967,5 +975,6 @@
     if (!config->dbh) {
         psError(PS_ERR_UNKNOWN, false, "Can't configure database");
-        goto FAIL;
+        psFree(config);
+        return NULL;
     }
 
@@ -975,9 +984,3 @@
 
     return config;
-
-FAIL:
-    psFree(config);
-    pmConfigDone();
-    psLibFinalize();
-    exit(EXIT_FAILURE);
 }
