MCPcopy Create free account
hub / github.com/crownengine/crown / main

Function main

src/device/main_linux.cpp:2507–2589  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2505} // namespace crown
2506
2507int main(int argc, char **argv)
2508{
2509 using namespace crown;
2510
2511 if (debug::callstack_init() != 0)
2512 return EXIT_FAILURE;
2513 if (atexit(at_exit) != 0) {
2514 debug::callstack_shutdown();
2515 return EXIT_FAILURE;
2516 }
2517
2518 struct sigaction act;
2519 // code-format off
2520 act.sa_handler = [](int signum) {
2521 switch (signum)
2522 {
2523 case SIGINT:
2524 case SIGTERM:
2525 if (device())
2526 device()->quit();
2527 break;
2528
2529 case SIGABRT:
2530 case SIGBUS:
2531 case SIGFPE:
2532 case SIGILL:
2533 case SIGPIPE:
2534 case SIGSEGV:
2535 case SIGSYS:
2536 error::abort("Signal %d", signum);
2537 break;
2538
2539 default:
2540 error::abort("Unhandled signal %d", signum);
2541 break;
2542 }
2543 };
2544 // code-format on
2545 sigemptyset(&act.sa_mask);
2546 act.sa_flags = 0;
2547 sigaction(SIGINT, &act, NULL);
2548 sigaction(SIGTERM, &act, NULL);
2549 sigaction(SIGABRT, &act, NULL);
2550 sigaction(SIGBUS, &act, NULL);
2551 sigaction(SIGFPE, &act, NULL);
2552 sigaction(SIGILL, &act, NULL);
2553 sigaction(SIGPIPE, &act, NULL);
2554 sigaction(SIGSEGV, &act, NULL);
2555 sigaction(SIGSYS, &act, NULL);
2556
2557#if CROWN_BUILD_UNIT_TESTS
2558 CommandLine cl(argc, (const char **)argv);
2559 if (cl.has_option("run-unit-tests")) {
2560 return main_unit_tests();
2561 }
2562#endif
2563
2564 InitGlobals m;

Callers

nothing calls this directly

Calls 11

deviceFunction · 0.85
main_unit_testsFunction · 0.85
main_data_compilerFunction · 0.85
quitMethod · 0.80
has_optionMethod · 0.80
sigactionClass · 0.70
callstack_initFunction · 0.50
callstack_shutdownFunction · 0.50
abortFunction · 0.50
parseMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected