Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>Edit:</strong></p> <p>It appears that I misread the question. The answer is simple:</p> <pre><code>handler1 () { do_something; } handler2 () { do_something_else; } handler3 () { handler1; handler2; } trap handler3 SIGNAL1 SIGNAL2 ... </code></pre> <hr> <p>Original:</p> <p>Just list multiple signals at the end of the command:</p> <pre><code>trap function-name SIGNAL1 SIGNAL2 SIGNAL3 ... </code></pre> <p>You can find the function associated with a particular signal using <code>trap -p</code>:</p> <pre><code>trap -p SIGINT </code></pre> <p>Note that it lists each signal separately even if they're handled by the same function.</p> <p>You can add an additional signal given a known one by doing this:</p> <pre><code>eval "$(trap -p SIGUSR1) SIGUSR2" </code></pre> <p>This works even if there are other additional signals being processed by the same function. In other words, let's say a function was already handling three signals - you could add two more just by referring to one existing one and appending two more (where only one is shown above just inside the closing quotes).</p> <p>If you're using Bash >= 3.2, you can do something like this to extract the function given a signal. Note that it's not completely robust because other single quotes could appear.</p> <pre><code>[[ $(trap -p SIGUSR1) =~ trap\ --\ \'([^\047])\'.* ]] function_name=${BASH_REMATCH[1]} </code></pre> <p>Then you could rebuild your trap command from scratch if you needed to using the function name, etc.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload