コード例 #1
0
ファイル: startup.c プロジェクト: andreiw/polaris
void			startup ()
{
	trap_signals ();

	if (mopen() == -1)
		scheduler_active = 0;
	else
		scheduler_active = 1;

	return;
}
コード例 #2
0
ファイル: signals.c プロジェクト: AlainODea/illumos-gate
void			ignore_signals ()
{
	switch (trapping) {

	case -1:	/* first time */
		trap_signals ();
		/*fall through*/

	case 1:		/* currently trapping */
		old_sighup = signal(SIGHUP, SIG_IGN);
		old_sigint = signal(SIGINT, SIG_IGN);
		old_sigquit = signal(SIGQUIT, SIG_IGN);
		old_sigterm = signal(SIGTERM, SIG_IGN);
		trapping = 0;
		break;

	case 0:		/* already ignoring */
		break;

	}
	return;
}
コード例 #3
0
ファイル: tpserver.c プロジェクト: openhoodie/hoodie
main(int argc, char *argv[])
{
	openlog("tpserver", LOG_PID|LOG_PERROR, LOG_DAEMON);
	Arguments(argc, argv);

	SWITCHBOARD = strdup(SWITCHBOARD);	/* I want to be able to modify it */
	char *p = strrchr(SWITCHBOARD, ':');
	if (!p)
	{	/* AF_UNIX address */
		master = socket(PF_UNIX, SOCK_STREAM, 0);
		if (master == -1)
			fatal("socket: %m");

		struct sockaddr_un my_addr = { AF_UNIX };
		strncat(my_addr.sun_path, SWITCHBOARD, sizeof(my_addr.sun_path));
		unlink(SWITCHBOARD);
		if (bind(master, (struct sockaddr *)&my_addr, sizeof my_addr) == -1)
			fatal("bind to %s: %m", my_addr.sun_path);
	}
	else
	{	/* AF_INET address */
		*p++ = 0;
		struct servent *service = getservbyname(p, "tcp");
		struct sockaddr_in my_addr;
		bzero(&my_addr, sizeof(my_addr));

		struct hostent *host = gethostbyname(SWITCHBOARD);
		if (!host)
			fatal("%s: %s", SWITCHBOARD, hstrerror(h_errno));
		bcopy(host->h_addr, &my_addr.sin_addr, host->h_length);
		my_addr.sin_family = host->h_addrtype;
		endhostent();

		my_addr.sin_port = service? service->s_port: htons(atoi(p));
		if (!ntohs(my_addr.sin_port))
			fatal("%s: No such service", p);
		endservent();

		master = socket(AF_INET, SOCK_STREAM, 0);
		if (master == -1)
			fatal("socket: %m");

		if (bind(master, (struct sockaddr *)&my_addr, sizeof my_addr) == -1)
		{
			p[-1] = ':';
			fatal("bind to %s: %m", SWITCHBOARD);
		}
	}

	if (listen(master, 5) == -1)
		fatal("listen to %s: %m", SWITCHBOARD);

	if (!DEBUG)
		switch (fork())
		{
		case -1:
			error("fork");
			exit(2);
		case 0:
			close(0);
			close(1);
			close(2);
			setsid();
			break;
		default:
			exit(0);
		}
	trap_signals();
	for (;;)
	{
		Iowait();
		debug(1, "------------------------------------------");
	}
	debug(1, "tpserver exit.  why?");
	return 15;
}
コード例 #4
0
int orcm_init(orcm_proc_type_t flags)
{
    int ret;
    char *error;
    int i, spin;

    if (NULL != getenv("ORCM_MCA_spin")) {
        spin = 1;
        /* spin until a debugger can attach */
        while (0 != spin) {
            ret = 0;
            while (ret < 10000) {
                ret++;
            };
        }
    }
    
    if (!orcm_util_initialized) {
        orcm_init_util();
    }
    
    /* set the default leader policy */
    orcm_default_leader_policy.jobid = ORTE_JOBID_WILDCARD;
    orcm_default_leader_policy.vpid = ORTE_VPID_WILDCARD;

    /* get the number of max msgs */
    mca_base_param_reg_int_name("orcm", "max_buffered_msgs",
                                "Number of recvd messages to hold in storage from each source",
                                false, false, ORCM_MAX_MSG_RING_SIZE, &orcm_max_msg_ring_size);

    /* independent mode or not */
    mca_base_param_reg_int_name("orcm", "sched_kill_dvm",
                                "Whether or not scheduler kills associated daemons upon termination (default: no)",
                                false, false, (int)false, &ret);
    orcm_sched_kill_dvm = OPAL_INT_TO_BOOL(ret);

    /* setup the globals that require initialization */
    orcm_triplets = OBJ_NEW(orcm_triplets_array_t);

#ifdef HAVE_QSYSTEM_H
#ifdef Q_SYSTEM_INTFCS_TO_PROBE_FOR_IP_ADDRESS
{
    char *eth_ifs[] = Q_SYSTEM_INTFCS_TO_PROBE_FOR_IP_ADDRESS;
    char **adds=NULL, *ifs, *envar;
    int i, num_ifs;

    num_ifs = sizeof(eth_ifs) / sizeof(eth_ifs[0]);
    for (i=0; i < num_ifs; i++) {
        opal_argv_append_nosize(&adds, eth_ifs[i]);
    }
    ifs = opal_argv_join(adds, ',');
    opal_argv_free(adds);
    /* push it into the environ so that the rmcast framework can get it */
    asprintf(&envar, "OMPI_MCA_rmcast_base_if_include=%s", ifs);
    putenv(envar);
    /* cannot release envar as the environ doesn't keep its own copy */
    free(ifs);
}
#endif
#endif

    /* initialize us */
    if (ORTE_SUCCESS != (ret = orte_init(NULL, NULL, flags))) {
        error = "orte_init";
        goto error;
    }

    if (!ORCM_PROC_IS_TOOL) {
        opal_set_using_threads(true);
    }

    if (!ORCM_PROC_IS_APP) {
        trap_signals();
    }

    orcm_initialized = true;
    
    return ORCM_SUCCESS;

error:
    if (ORCM_ERR_SILENT != ret) {
        orte_show_help("help-openrcm-runtime.txt",
                       "orcm_init:startup:internal-failure",
                       true, error, ORTE_ERROR_NAME(ret), ret);
    }
    
    return ret;
}
コード例 #5
0
ファイル: tail-comodo.c プロジェクト: jojje/tail-comodo
int main(int argc, char* argv[]) {
    int i;
    char* arg;
    char db_file[512];

    // Setup default configuration for the execution
    opts.cmd     = LAST_N;
    opts.c_recs  = 10;
    opts.sleep   = 1 * 1000;
    opts.verbose = FALSE;
    opts.db_file = db_file;
    opts.db      = 0;
    opts._last_row_id = -1;

    trap_signals();

    if(! find_db(db_file) )
        error("Failed to find cislogs.sdb, set the " ENV_VAR 
              " environment variable to the location to the file");
    
    // Command line parsing
    for(i=1; i<argc; i++){
        arg = argv[i];

        if( arg[0] == '-' ) {
            arg++;

            if( strlen(arg) == 0 ) {
                continue;

            } else if( arg[0] == 'h' || arg[0] == '?' ) {
                usage();

            } else if( isdigits(arg) ) {
                opts.c_recs = atoi(arg);

            } else if( strcmp("f",arg)==0 ) {
                opts.cmd = FOLLOW;

            } else if( strcmp("a",arg)==0 ) {
                opts.cmd = ALL;

            } else if( strcmp("v",arg)==0 ) {
                opts.verbose = TRUE;

            } else if( strcmp("V",arg)==0 ) {
                printf("Version: " VERSION "\n");
                terminate(0);

            } else if( strcmp("s",arg)==0 ) {
                if( i+1 < argc) {
                    arg = argv[++i];
                    if( !isdigits(arg) ) {
                        error("sleep interval must be numeric");
                    }
                    opts.sleep = atoi(arg) * 1000;
                    if( opts.sleep <= 0 ) {
                        error("sleep interval must be larger than zero");
                    }
                } else {
                    error("Option \"-s N\" must have number of seconds as an argument");
                }
            } else {
                error("Invalid option: %s", argv[i]);
            }
        } else {
            error("Invalid argument: %s", argv[i]);
        }

    } // END command line parsing

    if(opts.verbose) {
        printf("Using firewall db file: %s\n\n", opts.db_file);
    }
    tail();
    terminate(0);
}