Use typedef PyOS_sighandler_t and APIs PyOS_getsig() and
PyOS_setsig(), instead of directly calling signal() or sigaction().

This fixes the second half of bug #110611: the mysterious ignoring of
the first ^C when readline isn't used.
diff --git a/Modules/signalmodule.c b/Modules/signalmodule.c
index 1347c6d..9c5a18f 100644
--- a/Modules/signalmodule.c
+++ b/Modules/signalmodule.c
@@ -17,7 +17,7 @@
 #include <signal.h>
 
 #ifndef SIG_ERR
-#define SIG_ERR ((void (*)(int))-1)
+#define SIG_ERR ((PyOS_sighandler_t)(-1))
 #endif
 
 #if defined(PYOS_OS2)
@@ -38,7 +38,6 @@
 #endif
 
 
-
 /*
    NOTES ON THE INTERACTION BETWEEN SIGNALS AND THREADS
 
@@ -83,10 +82,9 @@
 static PyObject *IgnoreHandler;
 static PyObject *IntHandler;
 
-static void (*old_siginthandler)(int) = SIG_DFL;
+static PyOS_sighandler_t old_siginthandler = SIG_DFL;
 
 
-
 static PyObject *
 signal_default_int_handler(PyObject *self, PyObject *args)
 {
@@ -100,7 +98,6 @@
 The default handler for SIGINT instated by Python.\n\
 It raises KeyboardInterrupt.";
 
-
 
 static int
 checksignals_witharg(void * unused)
@@ -133,11 +130,10 @@
 #ifdef HAVE_SIGINTERRUPT
 	siginterrupt(sig_num, 1);
 #endif
-	signal(sig_num, signal_handler);
+	PyOS_setsig(sig_num, signal_handler);
 }
 
 
-
 #ifdef HAVE_ALARM
 static PyObject *
 signal_alarm(PyObject *self, PyObject *args)
@@ -181,7 +177,7 @@
 
 #endif
 
-
+
 static PyObject *
 signal_signal(PyObject *self, PyObject *args)
 {
@@ -217,7 +213,7 @@
 #ifdef HAVE_SIGINTERRUPT
 	siginterrupt(sig_num, 1);
 #endif
-	if (signal(sig_num, func) == SIG_ERR) {
+	if (PyOS_setsig(sig_num, func) == SIG_ERR) {
 		PyErr_SetFromErrno(PyExc_RuntimeError);
 		return NULL;
 	}
@@ -239,7 +235,7 @@
 A signal handler function is called with two arguments:\n\
 the first is the signal number, the second is the interrupted stack frame.";
 
-
+
 static PyObject *
 signal_getsignal(PyObject *self, PyObject *args)
 {
@@ -267,7 +263,7 @@
 anything else -- the callable Python object used as a handler\n\
 ";
 
-
+
 /* List of functions defined in the module */
 static PyMethodDef signal_methods[] = {
 #ifdef HAVE_ALARM
@@ -284,7 +280,6 @@
 };
 
 
-
 static char module_doc[] =
 "This module provides mechanisms to use signal handlers in Python.\n\
 \n\
@@ -346,14 +341,7 @@
 	Handlers[0].tripped = 0;
 	for (i = 1; i < NSIG; i++) {
 		void (*t)(int);
-#ifdef HAVE_SIGACTION
-		struct sigaction act;
-		sigaction(i,  0, &act);
-		t = act.sa_handler;
-#else
-		t = signal(i, SIG_IGN);
-		signal(i, t);
-#endif
+		t = PyOS_getsig(i);
 		Handlers[i].tripped = 0;
 		if (t == SIG_DFL)
 			Handlers[i].func = DefaultHandler;
@@ -368,7 +356,7 @@
 		Py_INCREF(IntHandler);
 		Py_DECREF(Handlers[SIGINT].func);
 		Handlers[SIGINT].func = IntHandler;
-		old_siginthandler = signal(SIGINT, &signal_handler);
+		old_siginthandler = PyOS_setsig(SIGINT, &signal_handler);
 	}
 
 #ifdef SIGHUP
@@ -555,7 +543,7 @@
 	int i;
 	PyObject *func;
 
-	signal(SIGINT, old_siginthandler);
+	PyOS_setsig(SIGINT, old_siginthandler);
 	old_siginthandler = SIG_DFL;
 
 	for (i = 1; i < NSIG; i++) {
@@ -564,7 +552,7 @@
 		Handlers[i].func = NULL;
 		if (i != SIGINT && func != NULL && func != Py_None &&
 		    func != DefaultHandler && func != IgnoreHandler)
-			signal(i, SIG_DFL);
+			PyOS_setsig(i, SIG_DFL);
 		Py_XDECREF(func);
 	}
 
@@ -577,7 +565,6 @@
 }
 
 
-
 /* Declared in pyerrors.h */
 int
 PyErr_CheckSignals(void)
@@ -615,7 +602,7 @@
 	return 0;
 }
 
-
+
 /* Replacements for intrcheck.c functionality
  * Declared in pyerrors.h
  */