Index: trunk/ippScripts/scripts/magic_process.pl
===================================================================
--- trunk/ippScripts/scripts/magic_process.pl	(revision 21371)
+++ trunk/ippScripts/scripts/magic_process.pl	(revision 22430)
@@ -28,4 +28,13 @@
 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
 use Pod::Usage qw( pod2usage );
+
+# Look for programs we need
+my $missing_tools;
+my $magictool      = can_run('magictool') or (warn "Can't find magictool" and $missing_tools = 1);
+my $removestreaks = can_run('RemoveStreaks') or (warn "Can't find RemoveStreaks" and $missing_tools = 1);
+if ($missing_tools) {
+    warn("Can't find required tools.");
+    exit($PS_EXIT_CONFIG_ERROR);
+}
 
 # Parse the command-line arguments
@@ -53,4 +62,8 @@
     defined $outroot;
 
+# Unhandled exceptions should be passed on to my_die so they get pushed into the database
+$SIG{__DIE__} = sub { die @_ if $^S;
+                      my_die( $_[0], $magic_id, $node, $PS_EXIT_UNKNOWN_ERROR ); };
+
 $ipprc->define_camera($camera);
 
@@ -66,15 +79,6 @@
 # resolve any path:// or file:// in outroot
 $outroot = $ipprc->file_resolve($outroot);
-    
+
 $ipprc->redirect_output($logfile) if $logfile;
-
-# Look for programs we need
-my $missing_tools;
-my $magictool      = can_run('magictool') or (warn "Can't find magictool" and $missing_tools = 1);
-my $removestreaks = can_run('RemoveStreaks') or (warn "Can't find RemoveStreaks" and $missing_tools = 1);
-if ($missing_tools) {
-    warn("Can't find required tools.");
-    exit($PS_EXIT_CONFIG_ERROR);
-}
 
 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files
@@ -145,5 +149,5 @@
         # this causes major file pollution, but avoids multi-level queries
         # at higher level nodes.
-        
+
         my ($in_fh, $input_list)  = open_list_file($outroot, "input.list");
         print $in_fh "$outroot\n";
@@ -252,5 +256,5 @@
 
     my $fh;
-    open $fh, "<$resolved" or 
+    open $fh, "<$resolved" or
         &my_die("failed to open streaks file $streaks_file", $magic_id, $node, $PS_EXIT_UNKNOWN_ERROR);
     # the first line in the streaks file contains the number of streaks found
@@ -259,5 +263,5 @@
     close $fh;
     print "$num_streaks streaks found on magicRun $magic_id\n" if $verbose;
-    
+
     my $command = "$magictool -addmask";
     $command   .= " -magic_id $magic_id";
