Changeset 5982 for branches/1.4/lang/tcl


Ignore:
Timestamp:
Feb 9, 2016, 8:26:30 AM (9 years ago)
Author:
gah
Message:

report signal name instead of exit code

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/1.4/lang/tcl/scripts/task.tcl

    r5981 r5982  
    1919
    2020itcl::class Rappture::Task {
     21    private method GetSignal { signal }
     22
    2123    public variable logger ""
    2224    public variable jobstats Rappture::Task::MiddlewareTime
     
    117119    }
    118120    return ""
     121}
     122
     123itcl::body Rappture::Task::GetSignal {code} {
     124    set signals {
     125        HUP INT QUIT ILL TRAP ABRT BUS FPE KILL USR1 SEGV
     126        USR2 PIPE ALRM TERM STKFLT CHLD CONT STOP TSTP TTIN
     127        TTOU URG XCPU XFSZ VTALRM PROF WINCH POLL PWR SYS
     128        RTMIN RTMIN+1 RTMIN+2 RTMIN+3 RTMAX-3 RTMAX-2 RTMAX-1 RTMAX
     129    }
     130    set sigNum [expr $code - 128]
     131    if { $sigNum > 0 && $sigNum < [llength $signals] } {
     132        return [lindex $signals $sigNum]
     133    }
     134    return "unknown exit code \"$code\""
    119135}
    120136
     
    293309                       # invalid result from the program.  Append the stderr
    294310                       # from the program to the message.
    295                        set logmesg "Program finished: exit code is $code"
     311                       if {$code > 128} {
     312                          set logmesg "Program signaled: signal was [GetSignal]"
     313                       } else {
     314                          set logmesg "Program finished: exit code is $code"
     315                       }
    296316                       set result "$logmesg\n\n$::Rappture::Task::job(error)"
    297317                    } elseif { $token == "abort" }  {
Note: See TracChangeset for help on using the changeset viewer.