Kyle Strand Kyle Strand - 7 months ago 36
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.


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