Author ABalmosan
Recipients ABalmosan
Date 2015-06-09.12:30:05
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1433853006.37.0.519208037884.issue24415@psf.upfronthosting.co.za>
In-reply-to
Content
We use the Python lib as part of a larger process. This process sets its own signal handlers to achieve the expected behavior of the process.

We use Py_InitializeEx(0) to prevent Python to install its own signal handlers.

On process reconfigure we shutdown Python with Py_Finalize() to call Py_InitializeEx(0) anew. 

Even so Py_InitializeEx(0) did not touch any signal and especially not SIGINT, Py_Finalize() resets unconditionally SIGINT to SIG_DFL.

The result is that our process terminates immediately on SIGINT instead of execution its shutdown procedure which was handled by the orginal installed SIGINT handler.

The problem is visible in the python code in 

Modules/signalmodule.c:
static void
finisignal(void)
{
    int i;
    PyObject *func;

    PyOS_setsig(SIGINT, old_siginthandler);
    old_siginthandler = SIG_DFL;


In Python/pythonrun.c Py_InitializeEx()I find:

    if (install_sigs)
        initsigs(); /* Signal handling stuff, including initintr() */


Also I wonder by whom PyOS_InitInterrupts() is called. It would unconditionally install the Python signal handler even if Py_InitializeEx(0) was once executed.
History
Date User Action Args
2015-06-09 12:30:06ABalmosansetrecipients: + ABalmosan
2015-06-09 12:30:06ABalmosansetmessageid: <1433853006.37.0.519208037884.issue24415@psf.upfronthosting.co.za>
2015-06-09 12:30:06ABalmosanlinkissue24415 messages
2015-06-09 12:30:05ABalmosancreate