Kyle Strand Kyle Strand - 1 year ago 85
Bash Question

Check if trap is set in Bash

Is there a way to check what

s have been set (in the current session or script) in Bash?

Ideally, I'd like to be able to get a list of the signals that have a
assigned to them, but if that's not possible I can just check each signal individually.

Answer Source

Let's define a function as follows:

$ function f
> {
> echo flfllf
> }

Let's set the trap to that function assigned to SIGINT

$ trap f SIGINT

Let's list set traps:

$ trap
trap -- 'f' SIGINT
trap -- '' SIGTSTP
trap -- '' SIGTTIN
trap -- '' SIGTTOU
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download