IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 1, 2026, 4:53:16 PM (7 weeks ago)
Author:
eugene
Message:

working on modernizing the error_code trapping

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-pstamp-20260421/pstamp/scripts/pstamp_job_run.pl

    r42981 r43048  
    1515use File::Copy;
    1616use File::Temp qw(tempfile tempdir);
     17use Scalar::Util qw(looks_like_number);
     18
    1719use Digest::MD5::File qw( file_md5_hex );
    1820use PS::IPP::PStamp::RequestFile qw( :standard );
     
    946948}
    947949
     950
     951# if the program exited normally, the exit value is returned
     952# if the program exited with a signal (abort, crash, etc), PS_EXIT_PROG_ERROR (4) is returned
     953# if the program failed to run, -PS_EXIT_PROG_ERROR (-4) is returned
     954sub parse_error_message {
     955    my $success = shift;
     956    my $error_msg = shift;
     957    my $command = shift;
     958
     959    if ($success) { return 0; }
     960
     961    print "raw error_msg: $error_msg\n";
     962    print "full command: $command\n";
     963
     964    if (&looks_like_number($error_msg)) { return (($error_msg >> 8) or ($PS_EXIT_PROG_ERROR)); }
     965       
     966    # which of these match?
     967    my ($error_code) = $error_msg =~ m/exited with value (\d+)/;
     968    if (defined $error_code) { return $error_code; }
     969   
     970    ($error_code) = $error_msg =~ m/died with signal (\d+)/;
     971#   if (defined $error_code) { return (128 + $error_code); }
     972    if (defined $error_code) { return ($PS_EXIT_PROG_ERROR); }
     973   
     974    # probably failed to execute:
     975    return (-1*$PS_EXIT_PROG_ERROR);
     976}
Note: See TracChangeset for help on using the changeset viewer.