Signal Handling (Cont)

Ignoring signals

     signal.signal(signo, signal.SIG_IGN)

Default behavior

     signal.signal(signo, signal.SIG_DFL)

Comments

  • Signal handlers remain installed until explicitly reset.
  • It is not possible to temporarily disable signals.
  • Signals are only handled between atomic instructions of the interpreter.
  • If a signal occurs during an I/O operation, it may fail with an exception (errno == EINTR).
  • Certain signals can't be handled from Python (SIGSEGV for instance).
  • Python handles a number of signals on its own (SIGINT, SIGTERM).
  • Mixing signals and threads is extremely problematic. Only main thread can deal with signals.
  • Signal handling on Windows and Macintosh is of limited functionality.
<<< O'Reilly OSCON 2000, Advanced Python Programming, Slide 59
July 17, 2000, beazley@cs.uchicago.edu
>>>