|
2 | 2 | // Copyright Pionix GmbH and Contributors to EVerest |
3 | 3 |
|
4 | 4 | #include <framework/runtime.hpp> |
5 | | - |
6 | | -#include <algorithm> |
7 | | -#include <atomic> |
8 | | -#include <cstdlib> |
9 | | -#include <fstream> |
10 | | - |
11 | | -#include <signal.h> |
12 | | - |
13 | | -#include <boost/program_options.hpp> |
14 | | - |
15 | 5 | #include <utils/error.hpp> |
16 | 6 | #include <utils/error/error_factory.hpp> |
17 | 7 | #include <utils/error/error_json.hpp> |
|
20 | 10 | #include <utils/error/error_state_monitor.hpp> |
21 | 11 | #include <utils/filesystem.hpp> |
22 | 12 |
|
23 | | -namespace Everest { |
24 | | - |
25 | | -namespace po = boost::program_options; |
26 | | - |
27 | | -namespace { |
28 | | - |
29 | | -static std::atomic_flag going_to_terminate = ATOMIC_FLAG_INIT; |
| 13 | +#include <algorithm> |
| 14 | +#include <cstdlib> |
| 15 | +#include <fstream> |
30 | 16 |
|
31 | | -void terminate_handler(int signal) { |
32 | | - if (going_to_terminate.test_and_set()) { |
33 | | - return; |
34 | | - } |
| 17 | +#include <boost/program_options.hpp> |
35 | 18 |
|
36 | | - // NOTE (aw): calling exit() in a signal handler is not advised due |
37 | | - // to race condition. For now we only do that in order for getting |
38 | | - // gcov `atexit` handlers to run (to write out coverage statistics). |
39 | | - // This should be properly handled by an event loop in the |
40 | | - // corresponding process. |
41 | | - exit(EXIT_FAILURE); |
42 | | -}; |
43 | | - |
44 | | -void setup_signal_handlers() { |
45 | | - struct sigaction action {}; |
46 | | - action.sa_handler = &terminate_handler; |
47 | | - // action.sa_mask should be zero, so no blocked signals within the signal handler |
48 | | - // action.sa_flags should be fine with being zero |
49 | | - sigaction(SIGINT, &action, nullptr); |
50 | | - sigaction(SIGTERM, &action, nullptr); |
51 | | -} |
| 19 | +namespace Everest { |
52 | 20 |
|
53 | | -} // namespace |
| 21 | +namespace po = boost::program_options; |
54 | 22 |
|
55 | 23 | std::string parse_string_option(const po::variables_map& vm, const char* option) { |
56 | 24 | if (vm.count(option) == 0) { |
@@ -430,16 +398,6 @@ ModuleCallbacks::ModuleCallbacks( |
430 | 398 |
|
431 | 399 | ModuleLoader::ModuleLoader(int argc, char* argv[], ModuleCallbacks callbacks, VersionInformation version_information) : |
432 | 400 | runtime_settings(nullptr), callbacks(std::move(callbacks)), version_information(std::move(version_information)) { |
433 | | - |
434 | | - // FIXME (aw): this shouldn't been done in this constructor, but |
435 | | - // rather in a seperate `framework/module_init` function. For now |
436 | | - // we're leaving it here as the signal handlers should be set up as |
437 | | - // early as possible - and the `ModuleLoader` is the thing, which |
438 | | - // gets constructed first. |
439 | | - // NOTE (aw): it was decided not to add this call to ev-cli in order |
440 | | - // to reduce the amount of generated code. |
441 | | - setup_signal_handlers(); |
442 | | - |
443 | 401 | if (!this->parse_command_line(argc, argv)) { |
444 | 402 | this->should_exit = true; |
445 | 403 | return; |
|
0 commit comments