title: Run code when Signal is sent, but do not trap the signal in Ruby
body: <p>I have code that is running on a server, before the server is hard shut down, a signal <code>SIGTERM</code> is sent to let my code know it needs to clean up. I want to run code when this happens and send the signal back to the same program so any other code that needs to clean up can do so. I do not want to trap the signal or change signal behavior, I only need to run something before the rest of my program interprets the SIGTERM.</p>
  
  <p>Currently I can do something like</p>
  
  <pre><code>Signal.trap('TERM') do
    puts "Graceful shutdown"
    exit
  end
  </code></pre>
  
  <p>but it doesn't work if multiple pieces of code in the same app try to do the same thing. For example:</p>
  
  <pre><code>Signal.trap('TERM') do
    puts "Graceful shutdown"
    exit
  end
  
  Signal.trap('TERM') do
    puts "Another graceful shutdown"
    exit
  end
  </code></pre>
  
  <p>You will only ever see <code>"Another graceful shutdown"</code> and the first code block will not run.</p>
  
  <p>Ideally I would be able to invoke current behavior with something like:</p>
  
  <pre><code>Signal.trap('TERM') do
    puts "another graceful shutdown"
    super
  end
  </code></pre>
  
  <p>But this doesn't work for obvious reasons. So the question is this: how can I run code when i get a <code>SIGTERM</code> without trapping it and preventing other code from doing the same?</p>