Index: /trunk/ippTools/src/detselect.c
===================================================================
--- /trunk/ippTools/src/detselect.c	(revision 11855)
+++ /trunk/ippTools/src/detselect.c	(revision 11856)
@@ -42,4 +42,8 @@
 
     pxConfig *config = detselectConfig(NULL, argc, argv);
+    if (!config) {
+        psError(PXTOOLS_ERR_CONFIG, false, "failed to configure");
+        goto FAIL;
+    }
 
     switch (config->mode) {
@@ -57,10 +61,12 @@
 
 FAIL:
+    psErrorStackPrint(stderr, "\n");
+    int exit_status = pxerrorGetExitStatus();
+
     psFree(config);
     pmConfigDone();
-    psErrorStackPrint(stderr, "\n");
     psLibFinalize();
 
-    exit(EXIT_FAILURE);
+    exit(exit_status);
 }
 
Index: /trunk/ippTools/src/detselectConfig.c
===================================================================
--- /trunk/ippTools/src/detselectConfig.c	(revision 11855)
+++ /trunk/ippTools/src/detselectConfig.c	(revision 11856)
@@ -28,6 +28,6 @@
 #include "detselect.h"
 
-// this function can not fail -- exits on error
-pxConfig *detselectConfig(pxConfig *config, int argc, char **argv) {
+pxConfig *detselectConfig(pxConfig *config, int argc, char **argv)
+{
     if (!config) {
         config = pxConfigAlloc();
@@ -40,5 +40,6 @@
     if (!config->modules) {
         psError(PS_ERR_UNKNOWN, false, "Can't find site configuration");
-        goto FAIL;
+        psFree(config);
+        return NULL;
     }
 
@@ -84,5 +85,6 @@
         if (config->mode) { \
             psError(PS_ERR_UNKNOWN, true, "only one mode selection is allowed"); \
-            goto FAIL; \
+            psFree(config); \
+            return NULL; \
         } \
         config->mode = modeval; \
@@ -126,5 +128,6 @@
 
         psFree(argSets);
-        goto FAIL;
+        psFree(config);
+        return NULL;
     }
 
@@ -139,5 +142,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; \
         } \
     } \
@@ -151,5 +155,6 @@
         if (!psMetadataAddS32(config->where, PS_LIST_TAIL, #name, 0, "==", s32)) { \
             psError(PS_ERR_UNKNOWN, false, "failed to add item " #name); \
-            goto FAIL; \
+            psFree(config); \
+            return NULL; \
         } \
     } \
@@ -164,5 +169,6 @@
             if (!psMetadataAddF32(config->where, PS_LIST_TAIL, #name, 0, "==", var)) { \
                 psError(PS_ERR_UNKNOWN, false, "failed to add item " #name); \
-                goto FAIL; \
+                psFree(config); \
+                return NULL; \
             } \
         } \
@@ -178,5 +184,6 @@
             if (!psMetadataAddF64(config->where, PS_LIST_TAIL, #name, 0, "==", var)) { \
                 psError(PS_ERR_UNKNOWN, false, "failed to add item " #name); \
-                goto FAIL; \
+                psFree(config); \
+                return NULL; \
             } \
         } \
@@ -192,5 +199,6 @@
         if (!time) { \
             psError(PS_ERR_UNKNOWN, false, "failed to convert " #name " into a psTime object"); \
-            goto FAIL; \
+            psFree(config); \
+            return NULL; \
         } \
         psMetadataItem *item = psMetadataLookup(config->args, "-" #name); \
@@ -202,5 +210,6 @@
         if (!psMetadataAddTime(config->where, PS_LIST_TAIL, #name, 0, str, time)) {\
             psError(PS_ERR_UNKNOWN, false, "failed to add item " #name); \
-            goto FAIL; \
+            psFree(config); \
+            return NULL; \
         } \
         psFree(time); \
@@ -221,5 +230,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;
             }
         }
@@ -248,5 +258,6 @@
     if (!config->dbh) {
         psError(PS_ERR_UNKNOWN, false, "Can't configure database");
-        goto FAIL;
+        psFree(config);
+        return NULL;
     }
 
@@ -256,10 +267,3 @@
 
     return config;
-
-FAIL:
-    psFree(config);
-    pmConfigDone();
-    psLibFinalize();
-
-    exit(EXIT_FAILURE);
-}
+}
