static void operation_loop(os_handler_t *os_hnd) { iposix_info_t *info = os_hnd->internal_data; sel_select_loop(info->sel, NULL, 0, NULL); }
static void operation_loop(os_handler_t *os_hnd) { pthread_t self = pthread_self(); pt_os_hnd_data_t *info = os_hnd->internal_data; sel_select_loop(info->sel, posix_thread_send_sig, (long) &self, info); }
int main(int argc, char *argv[]) { int rv; int curr_arg = 1; const char *arg; int full_screen = 1; ipmi_domain_id_t domain_id; int i; #ifdef HAVE_UCDSNMP int init_snmp = 0; #endif ipmi_args_t *con_parms[2]; ipmi_con_t *con[2]; int last_con = 0; selector_t *selector; while ((curr_arg < argc) && (argv[curr_arg][0] == '-')) { arg = argv[curr_arg]; curr_arg++; if (strcmp(arg, "--") == 0) { break; } else if (strcmp(arg, "-c") == 0) { full_screen = 0; } else if (strcmp(arg, "-dlock") == 0) { DEBUG_LOCKS_ENABLE(); } else if (strcmp(arg, "-dmem") == 0) { DEBUG_MALLOC_ENABLE(); } else if (strcmp(arg, "-drawmsg") == 0) { DEBUG_RAWMSG_ENABLE(); } else if (strcmp(arg, "-dmsg") == 0) { DEBUG_MSG_ENABLE(); #ifdef HAVE_UCDSNMP } else if (strcmp(arg, "-snmp") == 0) { init_snmp = 1; #endif } else { fprintf(stderr, "Unknown option: %s\n", arg); return 1; } } rv = ipmi_ui_init(&selector, full_screen); #ifdef HAVE_UCDSNMP if (init_snmp) { if (snmp_init(selector) < 0) goto out; } #endif next_con: rv = ipmi_parse_args(&curr_arg, argc, argv, &con_parms[last_con]); if (rv) { fprintf(stderr, "Error parsing command arguments, argument %d: %s\n", curr_arg, strerror(rv)); exit(1); } last_con++; if (curr_arg < argc) { if (last_con == 2) { fprintf(stderr, "Too many connections\n"); rv = EINVAL; goto out; } goto next_con; } for (i=0; i<last_con; i++) { rv = ipmi_args_setup_con(con_parms[i], &ipmi_ui_cb_handlers, selector, &con[i]); if (rv) { fprintf(stderr, "ipmi_ip_setup_con: %s", strerror(rv)); exit(1); } } for (i=0; i<last_con; i++) ipmi_free_args(con_parms[i]); rv = ipmi_open_domain("first", con, last_con, ipmi_ui_setup_done, NULL, NULL, NULL, NULL, 0, &domain_id); if (rv) { fprintf(stderr, "ipmi_init_domain: %s\n", strerror(rv)); goto out; } sel_select_loop(selector, NULL, 0, NULL); out: ipmi_ui_shutdown(); if (rv) return 1; return 0; }
int main(int argc, char *argv[]) { int i; int err; err = sel_alloc_selector(&ser2net_sel); if (err) { fprintf(stderr, "Could not initialize ser2net selector: '%s'\n", strerror(err)); return -1; } for (i=1; i<argc; i++) { if ((argv[i][0] != '-') || (strlen(argv[i]) != 2)) { fprintf(stderr, "Invalid argument: '%s'\n", argv[i]); arg_error(argv[0]); } switch (argv[i][1]) { case 'n': detach = 0; break; case 'd': detach = 0; debug = 1; break; case 'b': cisco_ios_baud_rates = 1; break; case 'C': /* Get a config line. */ i++; if (i == argc) { fprintf(stderr, "No config line specified with -C\n"); arg_error(argv[0]); } handle_config_line(argv[i]); config_file = NULL; break; case 'c': /* Get a config file. */ i++; if (i == argc) { fprintf(stderr, "No config file specified with -c\n"); arg_error(argv[0]); } config_file = argv[i]; break; case 'p': /* Get the control port. */ i++; if (i == argc) { fprintf(stderr, "No control port specified with -p\n"); arg_error(argv[0]); } config_port = argv[i]; break; case 'P': i++; if (i == argc) { fprintf(stderr, "No pid file specified with -P\n"); arg_error(argv[0]); } pid_file = argv[i]; break; #ifdef USE_UUCP_LOCKING case 'u': uucp_locking_enabled = 0; break; #endif case 'v': printf("%s version %s\n", argv[0], VERSION); exit(0); default: fprintf(stderr, "Invalid option: '%s'\n", argv[i]); arg_error(argv[0]); } } setup_sighup(); if (config_port != NULL) { if (controller_init(config_port) == -1) { fprintf(stderr, "Invalid control port specified with -p\n"); arg_error(argv[0]); } } if (debug && !detach) openlog("ser2net", LOG_PID | LOG_CONS | LOG_PERROR, LOG_DAEMON); if (config_file) { if (readconfig(config_file) == -1) { return 1; } } if (detach) { int pid; /* Detach from the calling terminal. */ openlog("ser2net", LOG_PID | LOG_CONS, LOG_DAEMON); syslog(LOG_NOTICE, "ser2net startup"); if ((pid = fork()) > 0) { exit(0); } else if (pid < 0) { syslog(LOG_ERR, "Error forking first fork"); exit(1); } else { /* setsid() is necessary if we really want to demonize */ setsid(); /* Second fork to really deamonize me. */ if ((pid = fork()) > 0) { exit(0); } else if (pid < 0) { syslog(LOG_ERR, "Error forking second fork"); exit(1); } } /* Close all my standard I/O. */ chdir("/"); close(0); close(1); close(2); } /* write pid file */ make_pidfile(pid_file); /* Ignore SIGPIPEs so they don't kill us. */ signal(SIGPIPE, SIG_IGN); set_sighup_handler(reread_config); sel_select_loop(ser2net_sel); return 0; }