title: Signal handler being called once per process
body: <p>I have a program that spawns multiple processes, and I kill it with Ctrl+C.</p>
  
  <p>At the start of the program I trap the signal in order to execute some cleanup operations.</p>
  
  <pre><code>def cleanup(*_):
      # do cleanup operations here
      # ...
      exit(1)
  
  # trap ctrl+c and hide the traceback message
  signal(SIGINT, cleanup)
  
  # spawn processes (pool of workers) and do work here
  # ...
  </code></pre>
  
  <p>The problem is that <code>cleanup</code> is being called multiple times (once per each running process).</p>
  
  <p>How can I make it so <code>cleanup</code> is only called once?</p>