int main(int argc, char **argv) { struct sigaction sig_stop; struct sigaction sig_time; _main = main_init(argc, argv); _log = log_init(); _main->conf = conf_init(argc, argv); _main->work = work_init(); _main->tcp = tcp_init(); _main->node = node_init(); _main->mime = mime_init(); /* Check configuration */ conf_print(); /* Catch SIG INT */ unix_signal(&sig_stop, &sig_time); /* Fork daemon */ unix_fork(log_console(_log)); /* Increase limits */ unix_limits(_main->conf->cores, CONF_EPOLL_MAX_EVENTS); /* Load mime types */ mime_load(); mime_hash(); /* Prepare TCP daemon */ tcp_start(); /* Drop privileges */ unix_dropuid0(); /* Start worker threads */ work_start(); /* Stop worker threads */ work_stop(); /* Stop TCP daemon */ tcp_stop(); mime_free(); node_free(); tcp_free(); work_free(); conf_free(); log_free(_log); main_free(); return 0; }
TAP_ESC::~TAP_ESC() { if (_initialized) { /* tell the task we want it to go away */ work_stop(); int i = 10; do { /* wait 50ms - it should wake every 100ms or so worst-case */ usleep(50000); i--; } while (_initialized && i > 0); } // clean up the alternate device node //unregister_class_devname(PWM_OUTPUT_BASE_DEVICE_PATH, _class_instance); tap_esc = nullptr; }
PX4FMU::~PX4FMU() { if (_initialized) { /* tell the task we want it to go away */ work_stop(); int i = 10; do { /* wait 50ms - it should wake every 100ms or so worst-case */ usleep(50000); i--; } while (_initialized && i > 0); } /* clean up the alternate device node */ unregister_class_devname(PWM_OUTPUT_BASE_DEVICE_PATH, _class_instance); g_fmu = NULL; }