Esempio n. 1
0
static void *APR_THREAD_FUNC worker_thread(apr_thread_t * thd, void *data)
{
    server_rec *main_server = data;

    pm_main(main_server, main_server->process->pconf);
    return NULL;
}
Esempio n. 2
0
// This requires the caller to have invoked pm_initialize_config prior to this
// call.
// It completes PM initialization and then starts the actual PM.
void
unified_sm_pm(uint32_t argc, uint8_t ** argv)
{
	mai_set_default_pkey(STL_DEFAULT_FM_PKEY);

    if (pm_config.debug_rmpp) if3RmppDebugOn();
    
	IB_LOG_INFO("Device: ", pm_config.hca);
	IB_LOG_INFO("Port: ", pm_config.port);

	pm_compute_pool_size();	// compute sizes for PM resources

    if (!pm_config.start) {
        IB_LOG_WARN0("PM not configured to start");
    } else {
        (void)sm_wait_ready(VIEO_PM_MOD_ID);
        (void)pm_main();
    }
}
Esempio n. 3
0
/*
 * Entry routine for the user application.
 * At this point, Initialize and start the user application.
 *
 * Entry routine is called from the initial task for Kernel,
 * so system call for stopping the task should not be issued
 * from the contexts of entry routine.
 * We recommend that:
 * (1)'usermain()' only generates the user initial task.
 * (2)initialize and start the user application by the user
 * initial task.
 */
EXPORT	INT	usermain( void )
{
	ER	err = E_OK;
	
	/* Start the device drivers */
#ifdef DRV_CONSOLE
	//err = ConsoleIO(0, NULL);
	tm_putstring(err >= E_OK ? "ConsoleIO - OK\n" : "ConsoleIO - ERR\n");
	vd_printf(err >= E_OK ? "ConsoleIO - OK\n" : "ConsoleIO - ERR\n");
#endif
#ifdef DRV_CLOCK
	err = ClockDrv(0, NULL);
	tm_putstring(err >= E_OK ? "ClockDrv - OK\n" : "ClockDrv - ERR\n");
	vd_printf(err >= E_OK ? "ClockDrv - OK\n" : "ClockDrv - ERR\n");
#endif
#ifdef DRV_SYSDISK
	err = SysDiskDrv(0, NULL);
	tm_putstring(err >= E_OK ? "SysDiskDrv - OK\n" : "SysDiskDrv - ERR\n");
	vd_printf(err >= E_OK ? "SysDiskDrv - OK\n" : "SysDiskDrv - ERR\n");
#endif
#ifdef DRV_SCREEN
	//err = ScreenDrv(0, NULL);
	tm_putstring(err >= E_OK ? "ScreenDrv - OK\n" : "ScreenDrv - ERR\n");
	vd_printf(err >= E_OK ? "ScreenDrv - OK\n" : "ScreenDrv - ERR\n");
#endif
#ifdef DRV_KBPD
	//err = KbPdDrv(0, NULL);
	tm_putstring(err >= E_OK ? "KbPdDrv - OK\n" : "KbPdDrv - ERR\n");
	vd_printf(err >= E_OK ? "KbPdDrv - OK\n" : "KbPdDrv - ERR\n");
#endif
#ifdef DRV_LOWKBPD
	//err = LowKbPdDrv(0, NULL);
	tm_putstring(err >= E_OK ? "LowKbPdDrv - OK\n" : "LowKbPdDrv - ERR\n");
	vd_printf(err >= E_OK ? "LowKbPdDrv - OK\n" : "LowKbPdDrv - ERR\n");
#endif
#ifdef DRV_NET
	err = NetDrv(0, NULL);
	tm_putstring(err >= E_OK ? "NetDrv - OK\n" : "NetDrv - ERR\n");
	vd_printf(err >= E_OK ? "NetDrv - OK\n" : "NetDrv - ERR\n");
#endif
	err = initKeyboard();
	
	if (err)vd_printf("err:initKeyborad\n");
	initVga();
	
	/* Start the T2EX extension modules */
#ifdef	USE_T2EX_DT
	err = dt_main(0, NULL);
	tm_putstring(err >= E_OK ? "dt_main(0) - OK\n":"dt_main(0) - ERR\n");
	vd_printf(err >= E_OK ? "dt_main(0) - OK\n":"dt_main(0) - ERR\n");
#endif
#ifdef	USE_T2EX_PM
	err = pm_main(0, NULL);
	tm_putstring(err >= E_OK ? "pm_main(0) - OK\n":"pm_main(0) - ERR\n");
	vd_printf(err >= E_OK ? "pm_main(0) - OK\n":"pm_main(0) - ERR\n");
#endif
#ifdef	USE_T2EX_FS
	err = fs_main(0, NULL);
	tm_putstring(err >= E_OK ? "fs_main(0) - OK\n":"fs_main(0) - ERR\n");
	vd_printf(err >= E_OK ? "fs_main(0) - OK\n":"fs_main(0) - ERR\n");
#endif
#ifdef	USE_T2EX_NET
	err = so_main(0, NULL);
	tm_putstring(err >= E_OK ? "so_main(0) - OK\n":"so_main(0) - ERR\n");
	vd_printf(err >= E_OK ? "so_main(0) - OK\n":"so_main(0) - ERR\n");
#endif
	/* Initialize stdio */
	libc_stdio_init();

	/* Start the T2EX application */
	tm_putstring("*** T2EX Application program start !!\n");

	appl_main();

	/* Shutdowm the T2EX extension modules */
#ifdef	USE_T2EX_DT
	err = dt_main(-1, NULL);
	tm_putstring(err >= E_OK ? "dt_main(-1) - OK\n":"dt_main(-1) - ERR\n");
#endif
#ifdef	USE_T2EX_PM
	err = pm_main(-1, NULL);
	tm_putstring(err >= E_OK ? "pm_main(-1) - OK\n":"pm_main(-1) - ERR\n");
#endif
#ifdef	USE_T2EX_FS
	err = fs_main(-1, NULL);
	tm_putstring(err >= E_OK ? "fs_main(-1) - OK\n":"fs_main(-1) - ERR\n");
#endif
#ifdef	USE_T2EX_NET
	err = so_main(-1, NULL);
	tm_putstring(err >= E_OK ? "so_main(-1) - OK\n":"so_main(-1) - ERR\n");
#endif

	/* Stop the device drivers */
#ifdef DRV_NET
	NetDrv(-1, NULL);
#endif
#ifdef DRV_LOWKBPD
	LowKbPdDrv(-1, NULL);
#endif
#ifdef DRV_KBPD
	KbPdDrv(-1, NULL);
#endif
#ifdef DRV_SCREEN
	ScreenDrv(-1, NULL);
#endif
#ifdef DRV_SYSDISK
	SysDiskDrv(-1, NULL);
#endif
#ifdef DRV_CLOCK
	ClockDrv(-1, NULL);
#endif
#ifdef DRV_CONSOLE
	ConsoleIO(-1, NULL);
#endif

	return 0;
}
Esempio n. 4
0
static apr_status_t
create_process_manager(server_rec * main_server, apr_pool_t * configpool)
{
    apr_status_t rv;

    g_process_manager =
        (apr_proc_t *) apr_pcalloc(configpool, sizeof(*g_process_manager));
    rv = apr_proc_fork(g_process_manager, configpool);
    if (rv == APR_INCHILD) {
        /* I am the child */
        g_pm_pid = getpid();
        ap_log_error(APLOG_MARK, APLOG_INFO, 0, main_server,
                     "mod_fcgid: Process manager %" APR_PID_T_FMT  " started", getpid());

        if ((rv = init_signal(main_server)) != APR_SUCCESS) {
            ap_log_error(APLOG_MARK, APLOG_EMERG, rv, main_server,
                         "mod_fcgid: can't install signal handler, exiting now");
            exit(DAEMON_STARTUP_ERROR);
        }

        /* If running as root, switch to configured user.
         *
         * When running children via suexec, only the effective uid is
         * switched, so that the PM can return to euid 0 to kill child
         * processes.
         *
         * When running children as the configured user, the real uid
         * is switched.
         */
        if (ap_unixd_config.suexec_enabled) {
            if (getuid() != 0) {
                ap_log_error(APLOG_MARK, APLOG_EMERG, 0, main_server,
                             "mod_fcgid: current user is not root while suexec is enabled, exiting now");
                exit(DAEMON_STARTUP_ERROR);
            }
            suexec_setup_child();
        } else
            ap_unixd_setup_child();
        apr_file_pipe_timeout_set(g_pm_read_pipe,
                                  apr_time_from_sec(g_wakeup_timeout));
        apr_file_close(g_ap_write_pipe);
        apr_file_close(g_ap_read_pipe);

        /* Initialize spawn controler */
        spawn_control_init(main_server, configpool);

        pm_main(main_server, configpool);

        ap_log_error(APLOG_MARK, APLOG_INFO, 0, main_server,
                     "mod_fcgid: Process manager %" APR_PID_T_FMT " stopped", getpid());
        exit(0);
    } else if (rv != APR_INPARENT) {
        ap_log_error(APLOG_MARK, APLOG_EMERG, rv, main_server,
                     "mod_fcgid: Create process manager error");
        exit(1);
    }

    /* I am the parent
       I will send the stop signal in procmgr_stop_procmgr() */
    apr_pool_note_subprocess(configpool, g_process_manager,
                             APR_KILL_ONLY_ONCE);
    apr_proc_other_child_register(g_process_manager, fcgid_maint,
                                  g_process_manager, NULL, configpool);

    return APR_SUCCESS;
}