title: Python signals for multiprocessing
body: <p>I would like to execute a certain signal handler in a multi-threading python program.
  I noted that my signal handler is called for main thread and the other thread (thread_1) that I have created.
  Is there any way to execute the signal handler only for thread_1?
  Or is there any way to know the thread ID of the thread that calls the signal handler? Is it the main thread or thread_1?</p>
  
  <pre><code>import signal
  import sys
  from multiprocessing import Process
  from time import sleep
  x = 3;
  
  def f(name):
      print 'hello', name
      while(1):
          sleep (1)
          print "AAAAAAAAAAAAAAAAAAAAAAAAA"
  
  def signal_handler(signal, frame):
      global x
      print 'You pressed Ctrl+C!'
      print x
      sys.exit(0)
  
  if __name__ == '__main__':
  
      signal.signal(signal.SIGINT, signal_handler)
      print 'Creating thread'
      p = Process(target=f, args=('bob',))
      p.start()
      print 'Press Ctrl+C'
      x += 6
      signal.pause()
      print 'After press CTRL+C'
  </code></pre>
  
  <p>Got an output:</p>
  
  <pre><code>Creating thread
  Press Ctrl+C
  hello bob
  AAAAAAAAAAAAAAAAAAAAAAAAA
  AAAAAAAAAAAAAAAAAAAAAAAAA
  AAAAAAAAAAAAAAAAAAAAAAAAA
  ^CYou pressed Ctrl+C!
  You pressed Ctrl+C!
  9
  3
  </code></pre>
  
  <p>As you can signal handler is called twice (one for main thread and another for thread_1), and as I asked above, I would like to execute handler only for thread_1 or even find a way to get thread_id of the calling thread?</p>