[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Handle SIGINT in C and Python

Victor Porton wrote:
> I need to assign a real C signal handler to SIGINT.
> This handler may be called during poll() waiting for data. For this reason
> I cannot use Python signals because "A Python signal handler does not get
> executed inside the low-level (C) signal handler. Instead, the low-level
> signal handler sets a flag which tells the virtual machine to execute the
> corresponding Python signal handler at a later point(for example at the
> next bytecode instruction)."
> I want after my signal handler for SIGINT executed to raise
> KeyboardInterrupt (as if I didn't installed my own signal handler).
> Is this possible? How?

I've found a solution: I can use PyOS_setsig() from Python implementation to 
get the old (Python default) OS-level signal handler, while I assign the new 

Victor Porton - http://portonvictor.org