MCPcopy Create free account
hub / github.com/Tiiny-AI/PowerInfer / ctrl_c_handling

Function ctrl_c_handling

smallthinker/tools/run/run.cpp:1220–1233  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1218}
1219
1220static void ctrl_c_handling() {
1221#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
1222 struct sigaction sigint_action;
1223 sigint_action.sa_handler = sigint_handler;
1224 sigemptyset(&sigint_action.sa_mask);
1225 sigint_action.sa_flags = 0;
1226 sigaction(SIGINT, &sigint_action, NULL);
1227#elif defined(_WIN32)
1228 auto console_ctrl_handler = +[](DWORD ctrl_type) -> BOOL {
1229 return (ctrl_type == CTRL_C_EVENT) ? (sigint_handler(SIGINT), true) : false;
1230 };
1231 SetConsoleCtrlHandler(reinterpret_cast<PHANDLER_ROUTINE>(console_ctrl_handler), true);
1232#endif
1233}
1234
1235int main(int argc, const char ** argv) {
1236 ctrl_c_handling();

Callers 1

mainFunction · 0.85

Calls 2

sigactionClass · 0.70
sigint_handlerFunction · 0.70

Tested by

no test coverage detected