Skip to content

Commit fa7906a

Browse files
committed
macOS: Add SIGTERM handler
1 parent 4130516 commit fa7906a

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/glfm_apple.m

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2999,6 +2999,17 @@ int main(int argc, const char * argv[]) {
29992999
[NSApplication sharedApplication];
30003000
}
30013001

3002+
// Add SIGTERM handler
3003+
// The SIGTERM signal is received when the user selects Quit from the dock icon menu.
3004+
// Note, this handler will not work when debugging.
3005+
signal(SIGTERM, SIG_IGN);
3006+
dispatch_source_t sigtermSource = dispatch_source_create(DISPATCH_SOURCE_TYPE_SIGNAL, SIGTERM, 0,
3007+
dispatch_get_main_queue());
3008+
dispatch_source_set_event_handler(sigtermSource, ^{
3009+
[NSApp terminate:nil];
3010+
});
3011+
dispatch_resume(sigtermSource);
3012+
30023013
// Set the delegate and run
30033014
GLFMAppDelegate *delegate = [GLFMAppDelegate new];
30043015
[NSApp setDelegate:delegate];

0 commit comments

Comments
 (0)