Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
use changesignal to restore SIGCHLD and SIGINT handling
Browse files Browse the repository at this point in the history
after GAP intialization, since we don't want it clobbering our own handlers for those
signals, or setting new ones

Something still needs to be done to replace the default SIGCHLD handler; see discussion at
gap-system/gap#3072 (comment)
  • Loading branch information
embray committed Dec 7, 2018
1 parent e11e438 commit b686acf
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/sage/libs/gap/util.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ Utility functions for libGAP
from __future__ import print_function, absolute_import

import os
import signal
import warnings

from cpython.exc cimport PyErr_SetObject
from cpython.object cimport Py_LT, Py_LE, Py_EQ, Py_NE, Py_GT, Py_GE
from cysignals.pysignals import changesignal
from cysignals.signals cimport sig_on, sig_off, sig_error

from .gap_includes cimport *
Expand Down Expand Up @@ -269,7 +271,13 @@ cdef initialize():
# Initialize GAP and capture any error messages
# The initialization just prints error and does not use the error handler
try:
GAP_Initialize(argc, argv, environ, &gasman_callback, &error_handler)
with changesignal(signal.SIGCHLD, signal.SIG_DFL), \
changesignal(signal.SIGINT, signal.SIG_DFL):
# Need to save/restore current SIGINT handling since GAP_Initialize
# currently clobbers it; it doesn't matter what we set SIGINT to
# temporarily.
GAP_Initialize(argc, argv, environ, &gasman_callback,
&error_handler)
except RuntimeError as msg:
raise RuntimeError('libGAP initialization failed\n' + msg)

Expand Down

0 comments on commit b686acf

Please sign in to comment.