int main (int argc, char *argv[]) { auto ret = ugcs::vsm::Run_as_service( "ugcs-vsm-ardrone", argc, argv, ugcs::vsm::Make_program_init_handler(start_main), ugcs::vsm::Make_callback(stop_main)); if (ret != ugcs::vsm::SERVICE_RESULT_NORMAL_INVOCATION) { return ret; } #ifdef __unix__ struct sigaction action; memset(&action, 0, sizeof(action)); action.sa_handler = Sigint_handler; sigaction(SIGINT, &action, NULL); #endif /* __unix__ */ start_main(argc, argv); wait_for_termination(); stop_main(); return 0; }
int main(int argc, char *argv[]) { ERR("power-manager start"); int c; int runflags = 0; /* run as daemon */ unsigned int flags = 0x0; /* 0 : start with noti */ while (1) { int option_index = 0; static struct option long_options[] = { {"foreground", no_argument, NULL, 'f'}, {"direct", no_argument, NULL, 'd'}, {"xdpms", no_argument, NULL, 'x'}, {0, 0, 0, 0} }; c = getopt_long(argc, argv, "fdx", long_options, &option_index); if (c == -1) break; switch (c) { case 'f': runflags = 1; break; case 'd': flags = flags | WITHOUT_STARTNOTI; /* 0x1 : start without noti */ break; case 'x': flags = flags | FLAG_X_DPMS; /* 0x2 : X control LCD onoff */ break; default: usage(); break; } } if (optind < argc) usage(); if (access(DEFAULT_PID_PATH, F_OK) == 0) { /* pid file exist */ printf ("Check the PM is running. If it isn't, delete \"%s\" and retry.\n", DEFAULT_PID_PATH); return -1; } if (!runflags) daemonize(); writepid(DEFAULT_PID_PATH); /* this function is main loop, defined in pm_core.c */ start_main(flags); unlink(DEFAULT_PID_PATH); return 0; }