void net_sim(char *debug_file_name) { struct net_t *net; double *inject_time; /* Next injection time (one per node) */ /* Initialize */ debug_init(); esim_init(); net_init(); net_debug_category = debug_new_category(debug_file_name); /* Network to work with */ if (!*net_sim_network_name) panic("%s: no network", __FUNCTION__); net = net_find(net_sim_network_name); if (!net) fatal("%s: network does not exist", net_sim_network_name); /* Initialize */ inject_time = xcalloc(net->node_count, sizeof(double)); /* FIXME: error for no dest node in network */ /* Simulation loop */ esim_process_events(TRUE); if (!strcmp(net_traffic_pattern, "") || (!strcmp(net_traffic_pattern, "uniform"))) { net_traffic_uniform(net, inject_time); } else if (!strcmp(net_traffic_pattern, "command")) { while (1) { long long cycle; cycle = esim_domain_cycle(net_domain_index); if (cycle >= net_max_cycles) break; net_debug("___cycle %lld___ \n", cycle); esim_process_events(TRUE); } } else fatal("Network %s: unknown traffic pattern (%s). \n", net->name, net_traffic_pattern); /* Drain events */ esim_process_all_events(); /* Free */ free(inject_time); /* Finalize */ net_done(); esim_done(); debug_done(); /* Finish program */ mhandle_done(); exit(0); }
void dram_system_sim (char *debug_file_name) { struct dram_system_t *dram_system; /* Initialize */ debug_init(); esim_init(); dram_system_init(); dram_debug_category = debug_new_category(debug_file_name); /* Getting the simulation name */ if (!*dram_sim_system_name) panic("%s: no DRAM simulation name", __FUNCTION__); dram_system = dram_system_find(dram_sim_system_name); if (!dram_system) fatal("%s: DRAM system does not exist", dram_sim_system_name); esim_process_events(TRUE); while (1) { long long cycle; cycle = esim_domain_cycle(dram_domain_index); if (cycle >= dram_system_max_cycles) break; if ((list_count(dram_system->dram_request_list)) && dram_system_get_request(dram_system)) list_dequeue(dram_system->dram_request_list); dram_system_process(dram_system); /* Next Cycle */ dram_debug("___cycle %lld___\n", cycle); esim_process_events(TRUE); } dram_system_done(); esim_done(); debug_done(); mhandle_done(); exit(0); }
int main(int argc, char **argv) { int res = 0, ch, longindex; pid_t pid; struct sigaction sa; setlinebuf(stdout); openlog(argv[0], LOG_PID, LOG_USER); res = pipe(stpg_init_report_pipe); if (res == -1) { res = -errno; PRINT_ERROR("Pipe failed: %d (%s)", res, strerror(-res)); goto out; } sa.sa_handler = &sig_chld; sigemptyset(&sa.sa_mask); sa.sa_flags = SA_RESTART | SA_NOCLDSTOP; if (sigaction(SIGCHLD, &sa, 0) == -1) { PRINT_ERROR("sigaction() failed: %d/%s", errno, strerror(errno)); exit(1); } /* * Otherwise we could die in some later write() during the event_loop() * instead of getting EPIPE! */ signal(SIGPIPE, SIG_IGN); res = debug_init(); if (res != 0) goto out; app_name = argv[0]; while ((ch = getopt_long(argc, argv, "+d:fp:t:hv", long_options, &longindex)) >= 0) { switch (ch) { case 'p': stpg_path = optarg; break; #if defined(DEBUG) || defined(TRACING) case 'd': trace_flag = strtol(optarg, (char **)NULL, 0); break; #endif case 'v': printf("%s version %s\n", app_name, VERSION_STR); goto out_done; case 'f': log_daemon = false; break; case 't': transition_timeout = strtol(optarg, (char **)NULL, 0); if (transition_timeout < 0) { printf("Invalid timeout %d\n", transition_timeout); res = -EINVAL; goto out_done; } break; case 'h': usage(0); goto out_done; default: goto out_usage; } } if (!stpg_path) stpg_path = "/usr/local/bin/scst/scst_on_stpg"; if (access(stpg_path, X_OK) == -1) { PRINT_ERROR("Script file \" %s \"does not exist or not " "executable", stpg_path); res = -1; goto out_done; } #ifdef DEBUG PRINT_INFO("trace_flag %lx", trace_flag); #endif if (log_daemon) { trace_flag &= ~TRACE_TIME; trace_flag &= ~TRACE_PID; pid = fork(); if (pid < 0) { PRINT_ERROR("starting daemon failed(%d)", pid); res = pid; goto out_done; } else if (pid) { int res1 = -1; close(stpg_init_report_pipe[1]); if ((unsigned)read(stpg_init_report_pipe[0], &res1, sizeof(res1)) < sizeof(res1)) { res = -1; goto out_done; } else { res = res1; goto out_done; } } close(0); open("/dev/null", O_RDWR); dup2(0, 1); dup2(0, 2); setsid(); } res = stpg_event_loop(); out_done: debug_done(); out: closelog(); return res; out_usage: usage(1); goto out_done; }
int main(int argc, char *argv[]) { #ifdef _USE_UNPACK int clean_tmp = 0; #endif int err = 0; int i; #ifdef __APPLE__ macosx_init(); #endif #ifndef S60 putenv("SDL_MOUSE_RELATIVE=0"); /* test this! */ #endif #ifdef _WIN32_WCE libwince_init(argv[0], 1); wince_init(argv[0]); #else #ifdef S60 extern char s60_data[]; strcpy(game_cwd, s60_data); #else #ifdef _WIN32 strcpy(game_cwd, dirname(argv[0])); #else if (!getcwd(game_cwd, sizeof(game_cwd))) fprintf(stderr,"Warning: can not get current dir\n."); #endif #endif #endif unix_path(game_cwd); setdir(game_cwd); for (i = 1; i < argc; i++) { if (!strcmp(argv[i], "-vsync")) vsync_sw = 1; else if (!strcmp(argv[i], "-nosound")) nosound_sw = 1; else if (!strcmp(argv[i], "-fullscreen")) fullscreen_sw = 1; else if (!strcmp(argv[i], "-mode")) { if ((i + 1) < argc) mode_sw = argv[++i]; else mode_sw = "-1x-1"; } else if (!strcmp(argv[i], "-window")) window_sw = 1; else if (!strcmp(argv[i], "-debug")) { if (!debug_sw) debug_init(); debug_sw = 1; } else if (!strcmp(argv[i], "-owntheme")) owntheme_sw = 1; else if (!strcmp(argv[i], "-noautosave")) noauto_sw = 1; else if (!strcmp(argv[i], "-game")) { if ((i + 1) < argc) game_sw = argv[++i]; else game_sw = ""; } else if (!strcmp(argv[i], "-theme")) { if ((i + 1) < argc) theme_sw = argv[++i]; else theme_sw = ""; } else if (!strcmp(argv[i], "-nostdgames")) { nostdgames_sw = 1; #ifdef _LOCAL_APPDATA } else if (!strcmp(argv[i], "-appdata")) { if ((i + 1) < argc) appdata_sw = argv[++i]; else appdata_sw = ""; #endif } else if (!strcmp(argv[i], "-chunksize")) { if ((i + 1) < argc) chunksize_sw = atoi(argv[++i]); else chunksize_sw = DEFAULT_CHUNKSIZE; } else if (!strcmp(argv[i], "-gamespath")) { if ((i + 1) < argc) games_sw = argv[++i]; else games_sw = ""; } else if (!strcmp(argv[i], "-themespath")) { if ((i + 1) < argc) themes_sw = argv[++i]; else themes_sw = ""; } else if (!strcmp(argv[i], "-idf")) { if ((i + 1) < argc) idf_sw = argv[++i]; else { fprintf(stderr,"No data directory specified.\n"); err = 1; goto out; } } else if (!strcmp(argv[i], "-encode")) { if ((i + 1) < argc) encode_sw = argv[++i]; else { fprintf(stderr,"No lua file specified.\n"); err = 1; goto out; } if ((i + 1) < argc) encode_output = argv[++i]; else encode_output = "lua.enc"; } else if (!strcmp(argv[i], "-version")) { version_sw = 1; } else if (!strcmp(argv[i], "-nopause")) { nopause_sw = 1; } else if (!strcmp(argv[i], "-software")) { software_sw = 1; #ifdef _USE_UNPACK } else if (!strcmp(argv[i], "-install")) { if ((i + 1) < argc) { char *file = argv[++i]; char *p; if (games_sw) p = games_sw; else p = game_local_games_path(1); if (setup_zip(file, p)) { err = 1; goto out; } } #endif } else if (!strcmp(argv[i], "-quit")) { exit(0); } else if (!strcmp(argv[i], "-hinting")) { if ((i + 1) < argc) hinting_sw = atoi(argv[++i]); else hinting_sw = 1; } else if (!strcmp(argv[i], "-lua") || !strcmp(argv[i], "-luac")) { if ((i + 1) < argc) { lua_exec = !strcmp(argv[i], "-lua"); lua_sw = argv[++ i]; opt_index = i + 1; break; } else { fprintf(stderr, "No lua script.\n"); err = 1; goto out; } } else if (!strcmp(argv[i], "-h") || !strcmp(argv[i], "-help") || !strcmp(argv[i], "--help")) { usage(); goto out; } else if (argv[i][0] == '-') { fprintf(stderr,"Unknown option: %s\n", argv[i]); usage(); err = 1; goto out; } else if (!start_idf(argv[i])) { fprintf(stderr, "Adding idf: %s\n", argv[i]); } else if (!run_game(argv[i])) { fprintf(stderr, "Opening game: %s\n", argv[i]); } #ifdef _USE_UNPACK else { char *p; if (games_sw) p = games_sw; else p = game_tmp_path(); if (setup_zip(argv[i], p)) { err = 1; goto out; } clean_tmp = 1; } #endif } cfg_load(); if (opt_debug == 1 && debug_sw == 0) { debug_sw = 1; debug_init(); } if (opt_vsync == 1 && vsync_sw == 0) vsync_sw = 1; if (version_sw) { fprintf(stdout, VERSION"\n"); goto out; } if (lua_sw) { err = instead_init_lua(dirname(lua_sw)); if (err) goto out; if (!err) err = instead_loadscript(lua_sw, argc - opt_index, argv + opt_index, lua_exec); instead_done(); goto out; } if (encode_sw) { err = instead_encode(encode_sw, encode_output); goto out; } if (idf_sw) { char *p = malloc(strlen(idf_sw) + 5); if (p) { char *b; strcpy(p, idf_sw); b = basename(p); strcat(b, ".idf"); idf_create(b, idf_sw); free(p); } else idf_create("data.idf", idf_sw); goto out; } menu_langs_lookup(dirpath(LANG_PATH)); if (!langs_nr) { fprintf(stderr, "No languages found in: %s.\n", dirpath(LANG_PATH)); err = 1; goto out; } if (!opt_lang || !opt_lang[0]) opt_lang = game_locale(); if (menu_lang_select(opt_lang) && menu_lang_select(LANG_DEF)) { fprintf(stderr, "Can not load default language.\n"); err = 1; goto out; } if (games_sw) games_lookup(games_sw); if (owntheme_sw && !opt_owntheme) { opt_owntheme = 2; } if (!nostdgames_sw && games_lookup(dirpath(GAMES_PATH))) fprintf(stderr, "No games found in: %s.\n", GAMES_PATH); if (themes_sw) themes_lookup(themes_sw); if (!nostdthemes_sw) { themes_lookup(dirpath(THEMES_PATH)); themes_lookup(game_local_themes_path()); } if (!nostdgames_sw) games_lookup(game_local_games_path(0)); if (start_idf_sw) { char *d, *b; char *dd, *bb; static char idf_game[255]; d = strdup(start_idf_sw); b = strdup(start_idf_sw); if (d && b) { dd = dirname(d); bb = basename(b); if (!games_replace(dirpath(dd), bb)) { game_sw = idf_game; strncpy(idf_game, bb, sizeof(idf_game) - 1); idf_game[sizeof(idf_game) - 1] = 0; } } if (d) free(d); if (b) free(b); } if (noauto_sw && opt_autosave) opt_autosave = 2; if (window_sw) opt_fs = 0; if (fullscreen_sw) opt_fs = 1; if (mode_sw) parse_mode(mode_sw, opt_mode); if (game_sw) { FREE(opt_game); opt_game = game_sw; } if (theme_sw) { FREE(opt_theme); opt_theme = theme_sw; } if (opt_theme) game_theme_select(opt_theme); if (!curtheme_dir) game_theme_select(DEFAULT_THEME); /* Initialize SDL */ if (gfx_init() < 0) return -1; #ifdef _USE_GTK gtk_init(&argc, &argv); /* must be called AFTER SDL_Init when using SDL2 */ #endif if (gfx_video_init() || input_init()) return -1; if (game_init(opt_game)) { game_error(); } game_loop(); cfg_save(); game_done(0); gfx_video_done(); #ifndef ANDROID gfx_done(); #endif out: if (debug_sw) debug_done(); #ifdef _USE_GTK /* gtk_main_quit (); */ #endif #ifdef _USE_UNPACK if (clean_tmp) remove_dir(game_tmp_path()); #endif #if defined(ANDROID) || defined(IOS) exit(err); #endif return err; }
void net_sim(char *debug_file_name) { struct net_t *net; double *inject_time; /* Next injection time (one per node) */ /* Initialize */ debug_init(); esim_init(); net_init(); net_debug_category = debug_new_category(debug_file_name); /* Network to work with */ if (!*net_sim_network_name) panic("%s: no network", __FUNCTION__); net = net_find(net_sim_network_name); if (!net) fatal("%s: network does not exist", net_sim_network_name); /* Network Trace = Stand Alone */ if (net_tracing()) { /* Initialization of Trace */ net_trace_header("net.init version=\"%d.%d\"\n", NET_SYSTEM_TRACE_VERSION_MAJOR, NET_SYSTEM_TRACE_VERSION_MINOR); /* Network Trace Header */ net_config_trace(net); } inject_time = xcalloc(net->node_count, sizeof(double)); /* FIXME: error for no dest node in network */ /* Simulation loop */ esim_process_events(TRUE); if (!strcmp(net_traffic_pattern, "") || (!strcmp(net_traffic_pattern, "uniform"))) { net_traffic_uniform(net, inject_time); } else if (!strcmp(net_traffic_pattern, "command")) { while(1) { long long cycle; cycle = esim_domain_cycle(net_domain_index); if (cycle >= net_max_cycles) break; net_debug("___cycle %lld___ \n", cycle); esim_process_events(TRUE); } } else fatal("Network %s: unknown traffic pattern (%s). \n", net->name ,net_traffic_pattern); /* Drain events */ esim_process_all_events(); /* Free */ free(inject_time); /* Finalize */ net_done(); esim_done(); trace_done(); debug_done(); }
int main(int argc, char **argv) { /* Initial information */ fprintf(stderr, "\n"); fprintf(stderr, "; Multi2Sim %s - A Simulation Framework for CPU-GPU Heterogeneous Computing\n", VERSION); fprintf(stderr, "; Please use command 'm2s --help' for a list of command-line options.\n"); fprintf(stderr, "; Last compilation: %s %s\n", __DATE__, __TIME__); fprintf(stderr, "\n"); /* Read command line */ sim_read_command_line(&argc, argv); /* CPU disassembler tool */ if (*cpu_disasm_file_name) ke_disasm(cpu_disasm_file_name); /* GPU disassembler tool */ if (*gpu_disasm_file_name) gk_disasm(gpu_disasm_file_name); /* OpenGL disassembler tool */ if (*opengl_disasm_file_name) gl_disasm(opengl_disasm_file_name, opengl_disasm_shader_index); /* GPU visualization tool */ if (*gpu_visual_file_name) vgpu_run(gpu_visual_file_name); /* Memory hierarchy visualization tool */ if (*visual_file_name) vmem_run(visual_file_name); /* Network simulation tool */ if (*net_sim_network_name) net_sim(net_debug_file_name); /* Debug */ debug_init(); isa_inst_debug_category = debug_new_category(isa_inst_debug_file_name); isa_call_debug_category = debug_new_category(isa_call_debug_file_name); elf_debug_category = debug_new_category(elf_debug_file_name); net_debug_category = debug_new_category(net_debug_file_name); ld_debug_category = debug_new_category(loader_debug_file_name); sys_debug_category = debug_new_category(syscall_debug_file_name); ctx_debug_category = debug_new_category(ctx_debug_file_name); mem_debug_category = debug_new_category(mem_debug_file_name); opencl_debug_category = debug_new_category(opencl_debug_file_name); gpu_isa_debug_category = debug_new_category(gpu_isa_debug_file_name); gpu_stack_debug_category = debug_new_category(gpu_stack_debug_file_name); /* GPU-REL */ gpu_faults_debug_category = debug_new_category(gpu_faults_debug_file_name); /* GPU-REL */ gpu_pipeline_debug_category = debug_new_category(gpu_pipeline_debug_file_name); error_debug_category = debug_new_category(error_debug_file_name); esim_debug_init(esim_debug_file_name); /* Trace */ trace_init(trace_file_name); mem_trace_category = trace_new_category(); /* Initialization for functional simulation */ esim_init(); ke_init(); net_init(); /* Initialization for detailed simulation */ if (cpu_sim_kind == cpu_sim_detailed) cpu_init(); if (gpu_sim_kind == gpu_sim_detailed) gpu_init(); /* Memory hierarchy initialization, done after we initialized CPU cores * and GPU compute units. */ mem_system_init(); /* Load programs */ cpu_load_progs(argc, argv, ctxconfig_file_name); /* Simulation loop */ if (ke->running_list_head) { if (cpu_sim_kind == cpu_sim_detailed) cpu_run(); else ke_run(); } /* Flush event-driven simulation */ esim_process_all_events(0); /* Dump statistics summary */ sim_stats_summary(); /* Finalization of memory system */ mem_system_done(); /* Finalization of detailed CPU simulation */ if (cpu_sim_kind == cpu_sim_detailed) { esim_debug_done(); cpu_done(); } /* Finalization of detailed GPU simulation */ if (gpu_sim_kind == gpu_sim_detailed) gpu_done(); /* Finalization */ net_done(); esim_done(); trace_done(); ke_done(); debug_done(); mhandle_done(); /* End */ return 0; }
int main(int argc, char **argv) { int res = 0; int ch, longindex; struct sigaction act; setlinebuf(stdout); res = debug_init(); if (res != 0) goto out; app_name = argv[0]; memset(devs, 0, sizeof(devs)); while ((ch = getopt_long(argc, argv, "+b:e:trongluF:I:cp:f:m:d:vsS:P:hDR:Z:", long_options, &longindex)) >= 0) { switch (ch) { case 'b': block_size = atoi(optarg); PRINT_INFO("block_size %x (%s)", block_size, optarg); block_shift = scst_calc_block_shift(block_size); if (block_shift < 9) { res = -EINVAL; goto out_usage; } break; case 'e': threads = strtol(optarg, (char **)NULL, 0); break; case 't': wt_flag = 1; break; #if defined(DEBUG) || defined(TRACING) case 'd': trace_flag = strtol(optarg, (char **)NULL, 0); break; #endif case 'r': rd_only_flag = 1; break; case 'o': o_direct_flag = 1; break; case 'n': nullio = 1; break; case 'c': nv_cache = 1; break; case 'p': if (strncmp(optarg, "std", 3) == 0) parse_type = SCST_USER_PARSE_STANDARD; else if (strncmp(optarg, "call", 3) == 0) parse_type = SCST_USER_PARSE_CALL; else if (strncmp(optarg, "excpt", 5) == 0) parse_type = SCST_USER_PARSE_EXCEPTION; else goto out_usage; break; case 'f': on_free_cmd_type_set = 1; if (strncmp(optarg, "ignore", 6) == 0) on_free_cmd_type = SCST_USER_ON_FREE_CMD_IGNORE; else if (strncmp(optarg, "call", 3) == 0) on_free_cmd_type = SCST_USER_ON_FREE_CMD_CALL; else goto out_usage; break; case 's': sgv_shared = 1; break; case 'S': sgv_single_alloc_pages = atoi(optarg); break; case 'P': sgv_purge_interval = atoi(optarg); break; case 'D': sgv_disable_clustered_pool = 1; break; case 'R': prealloc_buffers_num = atoi(optarg); break; case 'Z': prealloc_buffer_size = atoi(optarg) * 1024; break; case 'm': if (strncmp(optarg, "all", 3) == 0) memory_reuse_type = SCST_USER_MEM_REUSE_ALL; else if (strncmp(optarg, "read", 4) == 0) memory_reuse_type = SCST_USER_MEM_REUSE_READ; else if (strncmp(optarg, "write", 5) == 0) memory_reuse_type = SCST_USER_MEM_REUSE_WRITE; else if (strncmp(optarg, "none", 4) == 0) memory_reuse_type = SCST_USER_MEM_NO_REUSE; else goto out_usage; break; case 'l': non_blocking = 1; break; case 'I': vdisk_ID = strtol(optarg, (char **)NULL, 0); break; case 'F': flush_interval = strtol(optarg, (char **)NULL, 0); if (flush_interval < 0) { PRINT_ERROR("Wrong flush interval %d", flush_interval); flush_interval = 0; } break; case 'u': unreg_before_close = 1; break; #if defined(DEBUG_TM_IGNORE) || defined(DEBUG_TM_IGNORE_ALL) case 'g': debug_tm_ignore = 1; break; #endif case 'v': printf("%s version %s\n", app_name, VERSION_STR); goto out_done; default: goto out_usage; } } if (optind > (argc-2)) goto out_usage; if (!on_free_cmd_type_set && (memory_reuse_type != SCST_USER_MEM_REUSE_ALL)) on_free_cmd_type = SCST_USER_ON_FREE_CMD_CALL; PRINT_INFO("%s", "Options:"); if (rd_only_flag) PRINT_INFO(" %s", "READ ONLY"); if (wt_flag) PRINT_INFO(" %s", "WRITE THROUGH"); if (nv_cache) PRINT_INFO(" %s", "NV_CACHE"); if (o_direct_flag) PRINT_INFO(" %s", "O_DIRECT"); if (nullio) PRINT_INFO(" %s", "NULLIO"); if (non_blocking) PRINT_INFO(" %s", "NON-BLOCKING"); switch(parse_type) { case SCST_USER_PARSE_STANDARD: PRINT_INFO(" %s", "Standard parse"); break; case SCST_USER_PARSE_CALL: PRINT_INFO(" %s", "Call parse"); break; case SCST_USER_PARSE_EXCEPTION: PRINT_INFO(" %s", "Exception parse"); break; default: sBUG(); } switch(on_free_cmd_type) { case SCST_USER_ON_FREE_CMD_IGNORE: PRINT_INFO(" %s", "Ignore on_free_cmd"); break; case SCST_USER_ON_FREE_CMD_CALL: PRINT_INFO(" %s", "Call on_free_cmd"); break; default: sBUG(); } switch(memory_reuse_type) { case SCST_USER_MEM_REUSE_ALL: PRINT_INFO(" %s", "Full memory reuse enabled"); break; case SCST_USER_MEM_REUSE_READ: PRINT_INFO(" %s", "READ memory reuse enabled"); break; case SCST_USER_MEM_REUSE_WRITE: PRINT_INFO(" %s", "WRITE memory reuse enabled"); break; case SCST_USER_MEM_NO_REUSE: PRINT_INFO(" %s", "Memory reuse disabled"); break; default: sBUG(); } if (sgv_shared) PRINT_INFO(" %s", "SGV shared"); if (sgv_single_alloc_pages != 0) PRINT_INFO(" Use single entry SGV cache with %d pages/entry", sgv_single_alloc_pages); if (sgv_purge_interval != 0) { if (sgv_purge_interval > 0) PRINT_INFO(" Use SGV cache purge interval %d seconds", sgv_purge_interval); else PRINT_INFO(" %s", "SGV cache purging disabled"); } if (sgv_disable_clustered_pool) PRINT_INFO(" %s", "Disable clustered SGV pool"); if ((prealloc_buffers_num > 0) && (prealloc_buffer_size > 0)) PRINT_INFO(" Prealloc %d buffers of %dKB", prealloc_buffers_num, prealloc_buffer_size / 1024); if (!o_direct_flag && (memory_reuse_type == SCST_USER_MEM_NO_REUSE)) { PRINT_INFO(" %s", "Using unaligned buffers"); alloc_fn = malloc; } #if defined(DEBUG_TM_IGNORE) || defined(DEBUG_TM_IGNORE_ALL) if (debug_tm_ignore) PRINT_INFO(" %s", "DEBUG_TM_IGNORE"); #endif #ifdef DEBUG PRINT_INFO("trace_flag %lx", trace_flag); #endif memset(&act, 0, sizeof(act)); act.sa_handler = sigusr1_handler; act.sa_flags = SA_RESTART; sigemptyset(&act.sa_mask); res = sigaction(SIGUSR1, &act, NULL); if (res != 0) { res = errno; PRINT_ERROR("sigaction() failed: %s", strerror(res)); /* don't do anything */ } if (flush_interval != 0) { memset(&act, 0, sizeof(act)); act.sa_handler = sigalrm_handler; act.sa_flags = SA_RESTART; sigemptyset(&act.sa_mask); res = sigaction(SIGALRM, &act, NULL); if (res != 0) { res = errno; PRINT_ERROR("sigaction() failed: %s", strerror(res)); goto out_done; } res = alarm(flush_interval); if (res != 0) { res = errno; PRINT_ERROR("alarm() failed: %s", strerror(res)); goto out_done; } } res = start(argc, argv); out_done: debug_done(); out: return res; out_usage: usage(); goto out_done; }