Jelajahi Sumber

resource: restore original signal handler when sub-main returns

Daniele Bartolini 6 tahun lalu
induk
melakukan
3d3695977b
1 mengubah file dengan 7 tambahan dan 0 penghapusan
  1. 7 0
      src/resource/data_compiler.cpp

+ 7 - 0
src/resource/data_compiler.cpp

@@ -1072,10 +1072,12 @@ void DataCompiler::file_monitor_callback(void* thiz, FileMonitorEvent::Enum fme,
 int main_data_compiler(const DeviceOptions& opts)
 {
 #if CROWN_PLATFORM_POSIX
+	struct sigaction old_SIGINT;
 	struct sigaction act;
 	act.sa_handler = [](int /*signum*/) { _quit = true; };
 	sigemptyset(&act.sa_mask);
 	act.sa_flags = 0;
+	sigaction(SIGINT, NULL, &old_SIGINT);
 	sigaction(SIGINT, &act, NULL);
 #endif // CROWN_PLATFORM_POSIX
 
@@ -1164,6 +1166,11 @@ int main_data_compiler(const DeviceOptions& opts)
 	CE_DELETE(default_allocator(), dc);
 	console_server_globals::shutdown();
 
+#if CROWN_PLATFORM_POSIX
+	// Restore original handler
+	sigaction(SIGINT, &old_SIGINT, NULL);
+#endif // CROWN_PLATFORM_POSIX
+
 	return success ? EXIT_SUCCESS : EXIT_FAILURE;
 }