Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 9c85514

Browse filesBrowse files
committed
Use PyOS_setsig in macos backend
The docs for this function say it wraps `sigaction` or `signal`, and not to use those functions directly.
1 parent 1174aad commit 9c85514
Copy full SHA for 9c85514

File tree

Expand file treeCollapse file tree

1 file changed

+3
-6
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+3
-6
lines changed

‎src/_macosx.m

Copy file name to clipboardExpand all lines: src/_macosx.m
+3-6Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
static bool stdin_received = false;
4545
static bool stdin_sigint = false;
4646
// Global variable to store the original SIGINT handler
47-
static struct sigaction originalSigintAction = {0};
47+
static PyOS_sighandler_t originalSigintAction = NULL;
4848

4949
// Signal handler for SIGINT, only sets a flag to exit the run loop
5050
static void handleSigint(int signal) {
@@ -57,10 +57,7 @@ static int wait_for_stdin() {
5757
stdin_sigint = false;
5858

5959
// Set up a SIGINT handler to interrupt the event loop if ctrl+c comes in too
60-
struct sigaction customAction = {0};
61-
customAction.sa_handler = handleSigint;
62-
// Set the new handler and store the old one
63-
sigaction(SIGINT, &customAction, &originalSigintAction);
60+
originalSigintAction = PyOS_setsig(SIGINT, handleSigint);
6461

6562
// Create an NSFileHandle for standard input
6663
NSFileHandle *stdinHandle = [NSFileHandle fileHandleWithStandardInput];
@@ -93,7 +90,7 @@ static int wait_for_stdin() {
9390
[[NSNotificationCenter defaultCenter] removeObserver: stdinHandle];
9491

9592
// Restore the original SIGINT handler upon exiting the function
96-
sigaction(SIGINT, &originalSigintAction, NULL);
93+
PyOS_setsig(SIGINT, originalSigintAction);
9794
return 1;
9895
}
9996
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.