Index: /branches/eam_branches/ipp-pstamp-20260421/pstamp/scripts/psmkreq
===================================================================
--- /branches/eam_branches/ipp-pstamp-20260421/pstamp/scripts/psmkreq	(revision 43047)
+++ /branches/eam_branches/ipp-pstamp-20260421/pstamp/scripts/psmkreq	(revision 43048)
@@ -17,4 +17,5 @@
 use File::Temp qw(tempfile);
 use File::Basename qw(basename);
+use Scalar::Util qw(looks_like_number);
 use IPC::Cmd 0.36 qw( can_run run );
 use Carp;
@@ -295,9 +296,10 @@
     my $command = "$pstamp_request_file --input $table_def_name --req_name $req_name";
     $command .= " --output $output" if $output;
-    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
+    my ( $success, $error_msg, $full_buf, $stdout_buf, $stderr_buf ) =
         run(command => $command, verbose => $verbose);
+    my $error_code = &parse_error_message ($success, $error_msg, $command);
     unless ($success) {
         print STDERR @$stderr_buf;
-        exit $error_code >> 8;
+        exit $error_code;
     }
 }
@@ -447,2 +449,30 @@
 
 }
+
+# if the program exited normally, the exit value is returned
+# if the program exited with a signal (abort, crash, etc), PS_EXIT_PROG_ERROR (4) is returned
+# if the program failed to run, -PS_EXIT_PROG_ERROR (-4) is returned
+sub parse_error_message {
+    my $success = shift;
+    my $error_msg = shift;
+    my $command = shift;
+
+    if ($success) { return 0; }
+
+    print "raw error_msg: $error_msg\n";
+    print "full command: $command\n";
+
+    if (&looks_like_number($error_msg)) { return (($error_msg >> 8) or ($PS_EXIT_PROG_ERROR)); }
+	
+    # which of these match?
+    my ($error_code) = $error_msg =~ m/exited with value (\d+)/;
+    if (defined $error_code) { return $error_code; }
+    
+    ($error_code) = $error_msg =~ m/died with signal (\d+)/;
+#   if (defined $error_code) { return (128 + $error_code); }
+    if (defined $error_code) { return ($PS_EXIT_PROG_ERROR); }
+    
+    # probably failed to execute:
+    return (-1*$PS_EXIT_PROG_ERROR);
+}
+
Index: /branches/eam_branches/ipp-pstamp-20260421/pstamp/scripts/pstamp_finish.pl
===================================================================
--- /branches/eam_branches/ipp-pstamp-20260421/pstamp/scripts/pstamp_finish.pl	(revision 43047)
+++ /branches/eam_branches/ipp-pstamp-20260421/pstamp/scripts/pstamp_finish.pl	(revision 43048)
@@ -16,4 +16,5 @@
 use File::Copy;
 use File::Basename qw(dirname);
+use Scalar::Util qw(looks_like_number);
 
 use PS::IPP::Metadata::Config;
Index: /branches/eam_branches/ipp-pstamp-20260421/pstamp/scripts/pstamp_job_run.pl
===================================================================
--- /branches/eam_branches/ipp-pstamp-20260421/pstamp/scripts/pstamp_job_run.pl	(revision 43047)
+++ /branches/eam_branches/ipp-pstamp-20260421/pstamp/scripts/pstamp_job_run.pl	(revision 43048)
@@ -15,4 +15,6 @@
 use File::Copy;
 use File::Temp qw(tempfile tempdir);
+use Scalar::Util qw(looks_like_number);
+
 use Digest::MD5::File qw( file_md5_hex );
 use PS::IPP::PStamp::RequestFile qw( :standard );
@@ -946,2 +948,29 @@
 }
 
+
+# if the program exited normally, the exit value is returned
+# if the program exited with a signal (abort, crash, etc), PS_EXIT_PROG_ERROR (4) is returned
+# if the program failed to run, -PS_EXIT_PROG_ERROR (-4) is returned
+sub parse_error_message {
+    my $success = shift;
+    my $error_msg = shift;
+    my $command = shift;
+
+    if ($success) { return 0; }
+
+    print "raw error_msg: $error_msg\n";
+    print "full command: $command\n";
+
+    if (&looks_like_number($error_msg)) { return (($error_msg >> 8) or ($PS_EXIT_PROG_ERROR)); }
+	
+    # which of these match?
+    my ($error_code) = $error_msg =~ m/exited with value (\d+)/;
+    if (defined $error_code) { return $error_code; }
+    
+    ($error_code) = $error_msg =~ m/died with signal (\d+)/;
+#   if (defined $error_code) { return (128 + $error_code); }
+    if (defined $error_code) { return ($PS_EXIT_PROG_ERROR); }
+    
+    # probably failed to execute:
+    return (-1*$PS_EXIT_PROG_ERROR);
+}
Index: /branches/eam_branches/ipp-pstamp-20260421/pstamp/scripts/pstamp_parser_run.pl
===================================================================
--- /branches/eam_branches/ipp-pstamp-20260421/pstamp/scripts/pstamp_parser_run.pl	(revision 43047)
+++ /branches/eam_branches/ipp-pstamp-20260421/pstamp/scripts/pstamp_parser_run.pl	(revision 43048)
@@ -13,4 +13,5 @@
 use Getopt::Long qw( GetOptions );
 use File::Basename qw( basename dirname);
+use Scalar::Util qw(looks_like_number);
 use File::Copy;
 use POSIX qw( strftime );
@@ -128,8 +129,9 @@
     # if the uri is an http uri download the file 
     my $command = "$dsget --uri $uri --filename $new_uri --timeout 120";
-    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
-        run(command => $command, verbose => $verbose);
+    my ( $success, $error_msg, $full_buf, $stdout_buf, $stderr_buf ) =
+        run(command => $command, verbose => $verbose);
+    my $error_code = &parse_error_message ($success, $error_msg, $command);
     unless ($success) {
-        my_die("Unable to perform $command error code: $error_code", $req_id, $error_code >> 8);
+        my_die("Unable to perform $command error code: $error_code", $req_id, $error_code);
     }
 } elsif ($uri ne $new_uri) {
@@ -204,6 +206,7 @@
     $command   .= " -dbname $dbname" if $dbname;
     $command   .= " -dbserver $dbserver" if $dbserver;
-    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
-        run(command => $command, verbose => $verbose);
+    my ( $success, $error_msg, $full_buf, $stdout_buf, $stderr_buf ) =
+        run(command => $command, verbose => $verbose);
+    my $error_code = &parse_error_message ($success, $error_msg, $command);
     unless ($success) {
         die("Unable to perform $command error code: $error_code");
@@ -227,6 +230,7 @@
 
     my $command = "$parse_cmd";
-    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
-        run(command => $command, verbose => $verbose);
+    my ( $success, $error_msg, $full_buf, $stdout_buf, $stderr_buf ) =
+        run(command => $command, verbose => $verbose);
+    my $error_code = &parse_error_message ($success, $error_msg, $command);
 
     # save the contents of stderr (if any) to a file. This is relevant if
@@ -254,5 +258,5 @@
         }
     } else {
-        $fault = $error_code >> 8;
+        $fault = $error_code;
     }
 }
@@ -326,2 +330,30 @@
     exit $fault;
 }
+
+# if the program exited normally, the exit value is returned
+# if the program exited with a signal (abort, crash, etc), PS_EXIT_PROG_ERROR (4) is returned
+# if the program failed to run, -PS_EXIT_PROG_ERROR (-4) is returned
+sub parse_error_message {
+    my $success = shift;
+    my $error_msg = shift;
+    my $command = shift;
+
+    if ($success) { return 0; }
+
+    print "raw error_msg: $error_msg\n";
+    print "full command: $command\n";
+
+    if (&looks_like_number($error_msg)) { return (($error_msg >> 8) or ($PS_EXIT_PROG_ERROR)); }
+	
+    # which of these match?
+    my ($error_code) = $error_msg =~ m/exited with value (\d+)/;
+    if (defined $error_code) { return $error_code; }
+    
+    ($error_code) = $error_msg =~ m/died with signal (\d+)/;
+#   if (defined $error_code) { return (128 + $error_code); }
+    if (defined $error_code) { return ($PS_EXIT_PROG_ERROR); }
+    
+    # probably failed to execute:
+    return (-1*$PS_EXIT_PROG_ERROR);
+}
+
Index: /branches/eam_branches/ipp-pstamp-20260421/pstamp/scripts/pstamp_queue_cleanup.pl
===================================================================
--- /branches/eam_branches/ipp-pstamp-20260421/pstamp/scripts/pstamp_queue_cleanup.pl	(revision 43047)
+++ /branches/eam_branches/ipp-pstamp-20260421/pstamp/scripts/pstamp_queue_cleanup.pl	(revision 43048)
@@ -10,4 +10,5 @@
 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
 use Pod::Usage qw( pod2usage );
+use Scalar::Util qw(looks_like_number);
 
 my $verbose;
@@ -69,8 +70,9 @@
 
 my $command = "$pstamptool -updatereq -set_state goto_cleaned -state stop -timestamp_end $timestamp_end";
-my  ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
+my  ( $success, $error_msg, $full_buf, $stdout_buf, $stderr_buf ) =
     run(command => $command, verbose => $verbose);
+my $error_code = &parse_error_message ($success, $error_msg, $command);
 unless ($success) {
-    $error_code = (($error_code >> 8) or 1);
+    $error_code = ($error_code or 1);
     warn("$command failed. exit status: $error_code");
     exit $error_code;
@@ -79,2 +81,29 @@
 
 exit 0;
+
+# if the program exited normally, the exit value is returned
+# if the program exited with a signal (abort, crash, etc), PS_EXIT_PROG_ERROR (4) is returned
+# if the program failed to run, -PS_EXIT_PROG_ERROR (-4) is returned
+sub parse_error_message {
+    my $success = shift;
+    my $error_msg = shift;
+    my $command = shift;
+
+    if ($success) { return 0; }
+
+    print "raw error_msg: $error_msg\n";
+    print "full command: $command\n";
+
+    if (&looks_like_number($error_msg)) { return (($error_msg >> 8) or ($PS_EXIT_PROG_ERROR)); }
+	
+    # which of these match?
+    my ($error_code) = $error_msg =~ m/exited with value (\d+)/;
+    if (defined $error_code) { return $error_code; }
+    
+    ($error_code) = $error_msg =~ m/died with signal (\d+)/;
+#   if (defined $error_code) { return (128 + $error_code); }
+    if (defined $error_code) { return ($PS_EXIT_PROG_ERROR); }
+    
+    # probably failed to execute:
+    return (-1*$PS_EXIT_PROG_ERROR);
+}
Index: /branches/eam_branches/ipp-pstamp-20260421/pstamp/scripts/pstamp_queue_requests.pl
===================================================================
--- /branches/eam_branches/ipp-pstamp-20260421/pstamp/scripts/pstamp_queue_requests.pl	(revision 43047)
+++ /branches/eam_branches/ipp-pstamp-20260421/pstamp/scripts/pstamp_queue_requests.pl	(revision 43048)
@@ -11,4 +11,5 @@
 
 use Getopt::Long qw( GetOptions );
+use Scalar::Util qw(looks_like_number);
 
 use Sys::Hostname;
@@ -77,8 +78,9 @@
     $command .= " -dbserver $dbserver" if $dbserver;
 
-    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
+    my ( $success, $error_msg, $full_buf, $stdout_buf, $stderr_buf ) =
         run(command => $command, verbose => $verbose);
+    my $error_code = &parse_error_message ($success, $error_msg, $command);
     unless ($success) {
-        my $rc = $error_code >> 8;
+        my $rc = $error_code;
         die("Unable to perform pstamptool -datastore: $rc");
     }
@@ -121,9 +123,10 @@
         $command .= " --timeout $timeout";
 
-        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
+        my ( $success, $error_msg, $full_buf, $stdout_buf, $stderr_buf ) =
             run(command => $command, verbose => $verbose);
+	my $error_code = &parse_error_message ($success, $error_msg, $command);
         unless ($success) {
             # dsproductls exit status is the http error code - 300
-            my $exit_status = $error_code >> 8;
+            my $exit_status = $error_code;
 
             # don't die on "common faults"
@@ -167,6 +170,7 @@
         {
             my $command = "$dsfilesetls --uri $uri";
-            my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
+            my ( $success, $error_msg, $full_buf, $stdout_buf, $stderr_buf ) =
                     run(command => $command, verbose => $verbose);
+	    my $error_code = &parse_error_message ($success, $error_msg, $command);
             unless ($success) {
                 # we don't want to die here. We need to set lastFileset
@@ -197,6 +201,7 @@
                 $command .= " -dbserver $dbserver" if $dbserver;
 
-                my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
+                my ( $success, $error_msg, $full_buf, $stdout_buf, $stderr_buf ) =
                         run(command => $command, verbose => $verbose);
+		my $error_code = &parse_error_message ($success, $error_msg, $command);
 
                 unless ($success) {
@@ -208,13 +213,14 @@
 
         {
-        ## now update the last_fileset column in pstampDataStore
-        my $command = "$pstamptool -ds_id $ds_id -moddatastore -set_last_fileset $lastFileset";
-        $command .= " -dbname $dbname" if $dbname;
-        $command .= " -dbserver $dbserver" if $dbserver;
-        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
-            run(command => $command, verbose => $verbose);
-            unless ($success) {
-                die("Unable to perform pstamptool -moddatastore: $error_code");
-            }
+	    ## now update the last_fileset column in pstampDataStore
+	    my $command = "$pstamptool -ds_id $ds_id -moddatastore -set_last_fileset $lastFileset";
+	    $command .= " -dbname $dbname" if $dbname;
+	    $command .= " -dbserver $dbserver" if $dbserver;
+	    my ( $success, $error_msg, $full_buf, $stdout_buf, $stderr_buf ) =
+		run(command => $command, verbose => $verbose);
+	    my $error_code = &parse_error_message ($success, $error_msg, $command);
+	    unless ($success) {
+		die("Unable to perform pstamptool -moddatastore: $error_code");
+	    }
         }
         last if ($numFilesets >= $limit);
@@ -232,8 +238,36 @@
                 $command .= " -dbname $dbname" if $dbname;
                 $command .= " -dbserver $dbserver" if $dbserver;
-    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
+    my ( $success, $error_msg, $full_buf, $stdout_buf, $stderr_buf ) =
         run(command => $command, verbose => $verbose);
+    my $error_code = &parse_error_message ($success, $error_msg, $command);
     unless ($success) {
         die("Unable to perform pstamptool -moddatastore: $error_code");
     }
 }
+
+# if the program exited normally, the exit value is returned
+# if the program exited with a signal (abort, crash, etc), PS_EXIT_PROG_ERROR (4) is returned
+# if the program failed to run, -PS_EXIT_PROG_ERROR (-4) is returned
+sub parse_error_message {
+    my $success = shift;
+    my $error_msg = shift;
+    my $command = shift;
+
+    if ($success) { return 0; }
+
+    print "raw error_msg: $error_msg\n";
+    print "full command: $command\n";
+
+    if (&looks_like_number($error_msg)) { return (($error_msg >> 8) or ($PS_EXIT_PROG_ERROR)); }
+	
+    # which of these match?
+    my ($error_code) = $error_msg =~ m/exited with value (\d+)/;
+    if (defined $error_code) { return $error_code; }
+    
+    ($error_code) = $error_msg =~ m/died with signal (\d+)/;
+#   if (defined $error_code) { return (128 + $error_code); }
+    if (defined $error_code) { return ($PS_EXIT_PROG_ERROR); }
+    
+    # probably failed to execute:
+    return (-1*$PS_EXIT_PROG_ERROR);
+}
Index: /branches/eam_branches/ipp-pstamp-20260421/pstamp/scripts/pstamp_queue_update_cleanup.pl
===================================================================
--- /branches/eam_branches/ipp-pstamp-20260421/pstamp/scripts/pstamp_queue_update_cleanup.pl	(revision 43047)
+++ /branches/eam_branches/ipp-pstamp-20260421/pstamp/scripts/pstamp_queue_update_cleanup.pl	(revision 43048)
@@ -10,4 +10,5 @@
 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
 use Pod::Usage qw( pod2usage );
+use Scalar::Util qw(looks_like_number);
 
 my $verbose;
@@ -66,8 +67,9 @@
 
 my $command = "$pstamptool -pendingdependent -includefaulted -simple";
-my  ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
+my  ( $success, $error_msg, $full_buf, $stdout_buf, $stderr_buf ) =
     run(command => $command, verbose => $very_verbose);
+my $error_code = &parse_error_message ($success, $error_msg, $command);
 unless ($success) {
-    $error_code = (($error_code >> 8) or 1);
+    $error_code = ($error_code or 1);
     warn("$command failed. exit status: $error_code");
     exit $error_code;
@@ -86,8 +88,9 @@
         $command .= " -dbname $imagedb";
 
-        my  ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
+        my  ( $success, $error_msg, $full_buf, $stdout_buf, $stderr_buf ) =
             run(command => $command, verbose => $very_verbose);
+	my $error_code = &parse_error_message ($success, $error_msg, $command);
         unless ($success) {
-            $error_code = (($error_code >> 8) or 1);
+            $error_code = ($error_code or 1);
             warn("$command failed. exit status: $error_code");
             exit $error_code;
@@ -97,2 +100,29 @@
 
 exit 0;
+
+# if the program exited normally, the exit value is returned
+# if the program exited with a signal (abort, crash, etc), PS_EXIT_PROG_ERROR (4) is returned
+# if the program failed to run, -PS_EXIT_PROG_ERROR (-4) is returned
+sub parse_error_message {
+    my $success = shift;
+    my $error_msg = shift;
+    my $command = shift;
+
+    if ($success) { return 0; }
+
+    print "raw error_msg: $error_msg\n";
+    print "full command: $command\n";
+
+    if (&looks_like_number($error_msg)) { return (($error_msg >> 8) or ($PS_EXIT_PROG_ERROR)); }
+	
+    # which of these match?
+    my ($error_code) = $error_msg =~ m/exited with value (\d+)/;
+    if (defined $error_code) { return $error_code; }
+    
+    ($error_code) = $error_msg =~ m/died with signal (\d+)/;
+#   if (defined $error_code) { return (128 + $error_code); }
+    if (defined $error_code) { return ($PS_EXIT_PROG_ERROR); }
+    
+    # probably failed to execute:
+    return (-1*$PS_EXIT_PROG_ERROR);
+}
Index: /branches/eam_branches/ipp-pstamp-20260421/pstamp/scripts/pstamp_save_server_status.pl
===================================================================
--- /branches/eam_branches/ipp-pstamp-20260421/pstamp/scripts/pstamp_save_server_status.pl	(revision 43047)
+++ /branches/eam_branches/ipp-pstamp-20260421/pstamp/scripts/pstamp_save_server_status.pl	(revision 43048)
@@ -11,4 +11,5 @@
 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
 use Pod::Usage qw( pod2usage );
+use Scalar::Util qw(looks_like_number);
 
 my $updatelink;
@@ -63,8 +64,9 @@
 my $command = "pstamp_server_status --workdir $pstamp_workdir > $file";
 #my $command = "pstamp_server_status > $file";
-my  ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
+my  ( $success, $error_msgo, $full_buf, $stdout_buf, $stderr_buf ) =
     run(command => $command, verbose => $verbose);
+my $error_code = &parse_error_message ($success, $error_msg, $command);
 unless ($success) {
-    $error_code = (($error_code >> 8) or 1);
+    $error_code = ($error_code or 1);
     warn("$command failed. exit status: $error_code");
     exit $error_code;
@@ -80,2 +82,29 @@
 
 exit 0;
+
+# if the program exited normally, the exit value is returned
+# if the program exited with a signal (abort, crash, etc), PS_EXIT_PROG_ERROR (4) is returned
+# if the program failed to run, -PS_EXIT_PROG_ERROR (-4) is returned
+sub parse_error_message {
+    my $success = shift;
+    my $error_msg = shift;
+    my $command = shift;
+
+    if ($success) { return 0; }
+
+    print "raw error_msg: $error_msg\n";
+    print "full command: $command\n";
+
+    if (&looks_like_number($error_msg)) { return (($error_msg >> 8) or ($PS_EXIT_PROG_ERROR)); }
+	
+    # which of these match?
+    my ($error_code) = $error_msg =~ m/exited with value (\d+)/;
+    if (defined $error_code) { return $error_code; }
+    
+    ($error_code) = $error_msg =~ m/died with signal (\d+)/;
+#   if (defined $error_code) { return (128 + $error_code); }
+    if (defined $error_code) { return ($PS_EXIT_PROG_ERROR); }
+    
+    # probably failed to execute:
+    return (-1*$PS_EXIT_PROG_ERROR);
+}
Index: /branches/eam_branches/ipp-pstamp-20260421/pstamp/scripts/pstamp_server_status
===================================================================
--- /branches/eam_branches/ipp-pstamp-20260421/pstamp/scripts/pstamp_server_status	(revision 43047)
+++ /branches/eam_branches/ipp-pstamp-20260421/pstamp/scripts/pstamp_server_status	(revision 43048)
@@ -13,5 +13,5 @@
 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
 use Pod::Usage qw( pod2usage );
-
+use Scalar::Util qw(looks_like_number);
 
 my ($rundir, $workdir, $verbose, $save_temps);
@@ -71,10 +71,11 @@
     my $serverRunning = 0;
     my $command = "$pantasks_client < $pantasks_script";
-    my  ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
+    my  ( $success, $error_msg, $full_buf, $stdout_buf, $stderr_buf ) =
         run(command => $command, verbose => $verbose);
+    my $error_code = &parse_error_message ($success, $error_msg, $command);
     if ($success) {
         $serverRunning = 1;
     } else {
-        $error_code = (($error_code >> 8) or 1);
+        $error_code = ($error_code or 1);
         if ($error_code == 12 || $error_code == 13) {
             print "Postage Stamp Server is not running\n<br>";
@@ -205,2 +206,29 @@
 
 exit 0;
+
+# if the program exited normally, the exit value is returned
+# if the program exited with a signal (abort, crash, etc), PS_EXIT_PROG_ERROR (4) is returned
+# if the program failed to run, -PS_EXIT_PROG_ERROR (-4) is returned
+sub parse_error_message {
+    my $success = shift;
+    my $error_msg = shift;
+    my $command = shift;
+
+    if ($success) { return 0; }
+
+    print "raw error_msg: $error_msg\n";
+    print "full command: $command\n";
+
+    if (&looks_like_number($error_msg)) { return (($error_msg >> 8) or ($PS_EXIT_PROG_ERROR)); }
+	
+    # which of these match?
+    my ($error_code) = $error_msg =~ m/exited with value (\d+)/;
+    if (defined $error_code) { return $error_code; }
+    
+    ($error_code) = $error_msg =~ m/died with signal (\d+)/;
+#   if (defined $error_code) { return (128 + $error_code); }
+    if (defined $error_code) { return ($PS_EXIT_PROG_ERROR); }
+    
+    # probably failed to execute:
+    return (-1*$PS_EXIT_PROG_ERROR);
+}
Index: /branches/eam_branches/ipp-pstamp-20260421/pstamp/scripts/pstamp_webrequest.pl
===================================================================
--- /branches/eam_branches/ipp-pstamp-20260421/pstamp/scripts/pstamp_webrequest.pl	(revision 43047)
+++ /branches/eam_branches/ipp-pstamp-20260421/pstamp/scripts/pstamp_webrequest.pl	(revision 43048)
@@ -25,4 +25,6 @@
 my $req_name_prefix = 'web';
 my $username;
+
+my $DEBUG = 0;
 
 GetOptions(
@@ -93,5 +95,5 @@
     my $command = "$psmkreq --req_name $request_name  --output $request_file @ARGV";
 
-if (0) {
+if ($DEBUG) {
 open DEBUG, ">>/tmp/pstamp.debug.log";
 print DEBUG "\ncommand is: $command\n";
Index: /branches/eam_branches/ipp-pstamp-20260421/pstamp/scripts/pstampparse.pl
===================================================================
--- /branches/eam_branches/ipp-pstamp-20260421/pstamp/scripts/pstampparse.pl	(revision 43047)
+++ /branches/eam_branches/ipp-pstamp-20260421/pstamp/scripts/pstampparse.pl	(revision 43048)
@@ -15,4 +15,5 @@
 use File::Temp qw(tempfile);
 use File::Basename qw(basename);
+use Scalar::Util qw(looks_like_number);
 use Carp;
 use POSIX;
@@ -126,6 +127,7 @@
 {
     my $command = "echo $request_file_name | $fields -x 0 EXTNAME EXTVER REQ_NAME ACTION EMAIL";
-    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
+    my ( $success, $error_msg, $full_buf, $stdout_buf, $stderr_buf ) =
         run(command => $command, verbose => $verbose);
+    my $error_code = &parse_error_message ($success, $error_msg, $command);
 
     # note fields doesn't return zero when it succeeds.
@@ -184,7 +186,8 @@
     my $command = "$pstamptool -listreq  -name $req_name -not_req_id $req_id";
     # no verbose so that error message about request not found doesn't appear in parse_error.txt
-    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
+    my ( $success, $error_msg, $full_buf, $stdout_buf, $stderr_buf ) =
         run(command => $command, verbose => 0);
-    my $exitStatus = $error_code >> 8;
+    my $error_code = &parse_error_message ($success, $error_msg, $command);
+    my $exitStatus = $error_code;
     if ($success) {
         # -listreq succeeded there is already a request in the database with this name
@@ -781,5 +784,5 @@
 
     my $base = basename($image->{image});
-    if (! $base =~ /.fits$/ ) {
+    if (! ($base =~ /.fits$/) ) {
         my_die("unexpected image file name found $image->{image}", $PS_EXIT_PROG_ERROR);
     }
@@ -1136,8 +1139,9 @@
 
     if (!$no_update) {
-        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
+        my ( $success, $error_msg, $full_buf, $stdout_buf, $stderr_buf ) =
             run(command => $command, verbose => $verbose);
+	my $error_code = &parse_error_message ($success, $error_msg, $command);
         unless ($success) {
-            my $fault = $error_code >> 8;
+            my $fault = $error_code;
             print STDERR "$command failed with fault $fault\n";
             if ($fault < $PSTAMP_FIRST_ERROR_CODE) {
@@ -1421,2 +1425,30 @@
     exit $fault;
 }
+
+# if the program exited normally, the exit value is returned
+# if the program exited with a signal (abort, crash, etc), PS_EXIT_PROG_ERROR (4) is returned
+# if the program failed to run, -PS_EXIT_PROG_ERROR (-4) is returned
+sub parse_error_message {
+    my $success = shift;
+    my $error_msg = shift;
+    my $command = shift;
+
+    if ($success) { return 0; }
+
+    print "raw error_msg: $error_msg\n";
+    print "full command: $command\n";
+
+    if (&looks_like_number($error_msg)) { return (($error_msg >> 8) or ($PS_EXIT_PROG_ERROR)); }
+	
+    # which of these match?
+    my ($error_code) = $error_msg =~ m/exited with value (\d+)/;
+    if (defined $error_code) { return $error_code; }
+    
+    ($error_code) = $error_msg =~ m/died with signal (\d+)/;
+#   if (defined $error_code) { return (128 + $error_code); }
+    if (defined $error_code) { return ($PS_EXIT_PROG_ERROR); }
+    
+    # probably failed to execute:
+    return (-1*$PS_EXIT_PROG_ERROR);
+}
+
