title: Python process not responding with custom signal handler dealing with segmentation fault
body: <p>Python builtin signal handler not working consistently when dealing with signal related to segmentation fault. By using <code>kill</code> command to send SIGSEGV to the process, it works correctly. But when an illegal memory access inside the process happens, which is also a SIGSEGV signal, cannot be handled by the custom signal handler. </p>
  
  <pre class="lang-py prettyprint-override"><code>import ctypes
  import os
  import signal
  import time
  
  if __name__ == '__main__':
      def receiveSignal(signalNumber, frame):
          print('Received:', signalNumber)
          return
  
  
      print('My PID is:', os.getpid())
  
      # register the signals to be caught
      signal.signal(signal.SIGSEGV, receiveSignal)
      # raise a segmentation fault internally
      ctypes.string_at(0)
  
      # wait in an endless loop for signals
      while True:
          print('Waiting...')
          time.sleep(3)
  
  </code></pre>
  
  <p>I expect the segmentation fault(SIGSEGV) raised by <code>ctypes.string_at(0)</code> is caught by the signal handler, but it didn't, and the process stops responding to <code>ctrl+c</code>, <code>kill -2 PID</code> and <code>kill -11 PID</code>. </p>
  
  <p>However, I comment the <code>ctypes.string_at(0)</code> line, and send SIGSEGV with <code>kill -11 PID</code>, the signal is handled by my handler as expected. Besides, I don't understand that although the process doesn't respond, it keeps a 100% CPU usage.</p>
  
  <p>What is the difference between these two cases?</p>