• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (C) 2015-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
2 // This Source Code Form is subject to the terms of the Mozilla Public
3 // License, v. 2.0. If a copy of the MPL was not distributed with this
4 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 #ifndef VSOMEIP_ENABLE_SIGNAL_HANDLING
6 #include <csignal>
7 #endif
8 #include <vsomeip/vsomeip.hpp>
9 #include "hello_world_service.hpp"
10 
11 #ifndef VSOMEIP_ENABLE_SIGNAL_HANDLING
12 hello_world_service *hw_srv_ptr(nullptr);
handle_signal(int _signal)13     void handle_signal(int _signal) {
14         if (hw_srv_ptr != nullptr &&
15                 (_signal == SIGINT || _signal == SIGTERM))
16             hw_srv_ptr->terminate();
17     }
18 #endif
19 
main(int argc,char ** argv)20 int main(int argc, char **argv)
21 {
22     (void)argc;
23     (void)argv;
24 
25     hello_world_service hw_srv;
26 #ifndef VSOMEIP_ENABLE_SIGNAL_HANDLING
27     hw_srv_ptr = &hw_srv;
28     signal(SIGINT, handle_signal);
29     signal(SIGTERM, handle_signal);
30 #endif
31     if (hw_srv.init()) {
32         hw_srv.start();
33         return 0;
34     } else {
35         return 1;
36     }
37 }
38