| 805 | }; |
| 806 | |
| 807 | bool AppInitBasicSetup(const ArgsManager& args) |
| 808 | { |
| 809 | // ********************************************************* Step 1: setup |
| 810 | #ifdef _MSC_VER |
| 811 | // Turn off Microsoft heap dump noise |
| 812 | _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE); |
| 813 | _CrtSetReportFile(_CRT_WARN, CreateFileA("NUL", GENERIC_WRITE, 0, nullptr, OPEN_EXISTING, 0, 0)); |
| 814 | // Disable confusing "helpful" text message on abort, Ctrl-C |
| 815 | _set_abort_behavior(0, _WRITE_ABORT_MSG | _CALL_REPORTFAULT); |
| 816 | #endif |
| 817 | #ifdef WIN32 |
| 818 | // Enable heap terminate-on-corruption |
| 819 | HeapSetInformation(nullptr, HeapEnableTerminationOnCorruption, nullptr, 0); |
| 820 | #endif |
| 821 | if (!InitShutdownState()) { |
| 822 | return InitError(Untranslated("Initializing wait-for-shutdown state failed.")); |
| 823 | } |
| 824 | |
| 825 | if (!SetupNetworking()) { |
| 826 | return InitError(Untranslated("Initializing networking failed.")); |
| 827 | } |
| 828 | |
| 829 | #ifndef WIN32 |
| 830 | if (!args.GetBoolArg("-sysperms", false)) { |
| 831 | umask(077); |
| 832 | } |
| 833 | |
| 834 | // Clean shutdown on SIGTERM |
| 835 | registerSignalHandler(SIGTERM, HandleSIGTERM); |
| 836 | registerSignalHandler(SIGINT, HandleSIGTERM); |
| 837 | |
| 838 | // Reopen debug.log on SIGHUP |
| 839 | registerSignalHandler(SIGHUP, HandleSIGHUP); |
| 840 | |
| 841 | // Ignore SIGPIPE, otherwise it will bring the daemon down if the client closes unexpectedly |
| 842 | signal(SIGPIPE, SIG_IGN); |
| 843 | #else |
| 844 | SetConsoleCtrlHandler(consoleCtrlHandler, true); |
| 845 | #endif |
| 846 | |
| 847 | std::set_new_handler(new_handler_terminate); |
| 848 | |
| 849 | return true; |
| 850 | } |
| 851 | |
| 852 | bool AppInitParameterInteraction(const ArgsManager& args) |
| 853 | { |
no test coverage detected