MCPcopy Create free account
hub / github.com/COVESA/vsomeip / main

Function main

examples/routingmanagerd/routingmanagerd.cpp:120–166  ·  view source on GitHub ↗

* Parse command line options * -h | --help print usage information * -d | --daemonize start background processing by forking the process * -q | --quiet do _not_ use dlt logging * * and start processing. */

Source from the content-addressed store, hash-verified

118 * and start processing.
119 */
120int main(int argc, char** argv) {
121#ifndef VSOMEIP_ENABLE_SIGNAL_HANDLING
122 // Block all signals
123 sigset_t mask;
124 sigfillset(&mask);
125 sigprocmask(SIG_SETMASK, &mask, NULL);
126#endif
127 bool must_daemonize(false);
128 bool is_quiet(false);
129 if (argc > 1) {
130 for (int i = 0; i < argc; i++) {
131 std::string its_argument(argv[i]);
132 if (its_argument == "-d" || its_argument == "--daemonize") {
133 must_daemonize = true;
134 } else if (its_argument == "-q" || its_argument == "--quiet") {
135 is_quiet = true;
136 } else if (its_argument == "-h" || its_argument == "--help") {
137 std::cout << "usage: " << argv[0] << " [-h|--help][-d|--daemonize][-q|--quiet]" << std::endl;
138 return 0;
139 }
140 }
141 }
142
143 /* Fork the process if processing shall be done in the background */
144 if (must_daemonize) {
145 pid_t its_process, its_signature;
146
147 its_process = fork();
148
149 if (its_process < 0) {
150 return EXIT_FAILURE;
151 }
152
153 if (its_process > 0) {
154 return EXIT_SUCCESS;
155 }
156
157 umask(0111);
158
159 its_signature = setsid();
160 if (its_signature < 0) {
161 return EXIT_FAILURE;
162 }
163 }
164
165 return routingmanagerd_process(is_quiet);
166}

Callers

nothing calls this directly

Calls 1

routingmanagerd_processFunction · 0.85

Tested by

no test coverage detected