tags:

views:

154

answers:

2
+1  A: 

No documentation hints of any argument or variable holding the signal that was trapped, so you'll have to write a function/trap statement for each trap you want to behave differently.

nos
thank you. that saves me digging around even further.
Wolf
A: 

You can implement your own trap function that automatically passes the signal to the function:

trap_with_arg() {
    func="$1" ; shift
    for sig ; do
        trap "$func $sig" "$sig"
    done
}

$ trap_with_arg func_trap INT TERM EXIT

The first argument to func_trap will be the name of the signal.

camh
very cool! I'm still trying to comprehend... twists my brain a little... :-) thanks!
Wolf