void Command::print_arguments(const std::string& command) { if (m_vout.verbose()) { m_vout << "Started osmium " << command << '\n' << " " << get_osmium_long_version() << '\n' << " " << get_libosmium_version() << '\n' << "Command line options and default settings:\n"; show_arguments(); } }
int main(int argc, char ** argv) { int ret = 0; struct sigaction act; ret = parse_arguments(argc, argv); if(ret != 0) show_arguments(); if(ret < 0) return EINVAL; if(ret > 0) return 0; show_info(); /* Connect the signal handlers */ act.sa_handler = handler; act.sa_flags = 0; sigemptyset(&(act.sa_mask)); sigaddset(&(act.sa_mask), SIGTERM); sigaddset(&(act.sa_mask), SIGQUIT); sigaddset(&(act.sa_mask), SIGINT); sigaction(SIGTERM, &act, NULL); sigaction(SIGQUIT, &act, NULL); sigaction(SIGINT, &act, NULL); if(daemon_mode) { ret = daemon(0, 0); if(ret == -1) { perror("An error occured while daemonizing."); exit(-1); } } struct liblttd_callbacks* callbacks = liblttdvfs_new_callbacks(trace_name, append_mode, verbose_mode); instance = liblttd_new_instance(callbacks, channel_name, num_threads, dump_flight_only, dump_normal_only, verbose_mode); if(!instance) { perror("An error occured while creating the liblttd instance"); return ret; } liblttd_start_instance(instance); return ret; }
int main(int argc, char ** argv) { int ret = 0; struct sigaction act; pthread_t *tids; unsigned long i; void *tret; ret = parse_arguments(argc, argv); if(ret != 0) show_arguments(); if(ret < 0) return EINVAL; if(ret > 0) return 0; show_info(); /* Connect the signal handlers */ act.sa_handler = handler; act.sa_flags = 0; sigemptyset(&(act.sa_mask)); sigaddset(&(act.sa_mask), SIGTERM); sigaddset(&(act.sa_mask), SIGQUIT); sigaddset(&(act.sa_mask), SIGINT); sigaction(SIGTERM, &act, NULL); sigaction(SIGQUIT, &act, NULL); sigaction(SIGINT, &act, NULL); if(ret = channels_init()) return ret; if(daemon_mode) { ret = daemon(0, 0); if(ret == -1) { perror("An error occured while daemonizing."); exit(-1); } } tids = malloc(sizeof(pthread_t) * num_threads); for(i=0; i<num_threads; i++) { ret = pthread_create(&tids[i], NULL, thread_main, (void*)i); if(ret) { perror("Error creating thread"); break; } } for(i=0; i<num_threads; i++) { ret = pthread_join(tids[i], &tret); if(ret) { perror("Error joining thread"); break; } if((long)tret != 0) { printf("Error %s occured in thread %u\n", strerror((long)tret), i); } } free(tids); ret = unmap_channels(&fd_pairs); close_channel_trace_pairs(&fd_pairs, inotify_fd, &inotify_watch_array); if(inotify_fd >= 0) close(inotify_fd); return ret; }
int main(int argc, char **argv) { int ret; ret = parse_arguments(argc, argv); /* If user needs show help, we disregard other options */ if (opt_help) { show_arguments(); return 0; } /* exit program if arguments wrong */ if (ret) return 1; show_info(); ret = lttctl_init(); if (ret != 0) return ret; if (opt_create) { printf("lttctl: Creating trace\n"); ret = lttctl_create_trace(); if (ret) goto op_fail; if (opt_write) { printf("lttctl: Forking lttd\n"); ret = lttctl_daemon(0); if (ret) goto op_fail; } } if (opt_start) { printf("lttctl: Starting trace\n"); ret = lttctl_start(opt_tracename); if (ret) goto op_fail; } if (opt_pause) { printf("lttctl: Pausing trace\n"); ret = lttctl_pause(opt_tracename); if (ret) goto op_fail; } if (opt_destroy) { if (opt_write) { printf("lttctl: Forking lttd\n"); ret = lttctl_daemon(1); if (ret) goto op_fail; } printf("lttctl: Destroying trace\n"); ret = lttctl_destroy_trace(opt_tracename); if (ret) goto op_fail; } op_fail: lttctl_destroy(); return ret; }