Skip to content

Commit 1e7e34c

Browse files
committed
Do not fail exiting a context if we fail to restore signal handlers
1 parent 564e710 commit 1e7e34c

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/SignalModuleBuiltins.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,12 @@ public static void resetSignalHandlers(PythonModule mod) {
204204
ModuleData data = mod.getModuleState(ModuleData.class);
205205
if (data != null) {
206206
for (Map.Entry<Integer, SignalHandler> entry : data.defaultSignalHandlers.entrySet()) {
207-
Signals.setSignalHandler(entry.getKey(), entry.getValue());
207+
try {
208+
Signals.setSignalHandler(entry.getKey(), entry.getValue());
209+
} catch (IllegalArgumentException e) {
210+
// Resetting the signal handlers to their original values is best-effort and
211+
// may not work, so we ignore errors here.
212+
}
208213
}
209214
data.signalHandlers.clear();
210215
data.defaultSignalHandlers.clear();

0 commit comments

Comments
 (0)