示例#1
0
文件: main.c 项目: aquirel/morrigan
static void __stop(int unused)
{
    #pragma ref unused

    static bool stopped = false;

    if (stopped)
    {
        return;
    }

    stopped = true;
    puts("Stopping morrigan.");
    if (input)
    {
        bdestroy(input);
    }
    net_stop();
    game_stop();
    server_stop();
    if (l)
    {
        landscape_destroy(l);
        l = NULL;
    }
}
示例#2
0
文件: module.c 项目: mvidner/linuxrc
void mod_menu()
{
  char *items[MAX_MODULE_TYPES + 3];
  int i;
  int again;

  net_stop();

  do {
    mod_update_list();

    for(mod_types = 0, i = 1 /* 0 is reserved for 'autoload' */; i < MAX_MODULE_TYPES; i++) {
      if(mod_show_type(i)) {
        mod_type[mod_types] = i;
        items[mod_types++] = mod_get_title(i);
      }
    }

    i = mod_types;

    items[i++] = "Show Loaded Modules";
    items[i++] = "Unload Modules";
    items[i++] = "Add Driver Update";
    items[i++] = "Show Driver Updates";

    items[i] = NULL;

    again = dia_list("Kernel Modules (Hardware Drivers)", 40, mod_menu_cb, items, mod_menu_last, align_center);

    for(i = 0; i < mod_types; i++) free(items[i]);
  }
  while(again);
}
示例#3
0
文件: config.c 项目: meloun/lnx_myweb
int user_stop (void)
{
//	terminate_process (httpd_pidfile, 0);

	sys_stop ();
	net_stop ();
	io_stop ();
	pm_stop ();

	return 0;
}
示例#4
0
void tipc_net_stop(void)
{
	if (tipc_mode != TIPC_NET_MODE)
		return;
	write_lock_bh(&tipc_net_lock);
	tipc_bearer_stop();
	tipc_mode = TIPC_NODE_MODE;
	tipc_bclink_stop();
	net_stop();
	write_unlock_bh(&tipc_net_lock);
	info("Left network mode\n");
}
示例#5
0
文件: ct.c 项目: mkatkar/libct
static int local_ct_wait(ct_handler_t h)
{
	struct container *ct = cth2ct(h);
	int ret, status;

	if (ct->state != CT_RUNNING)
		return -LCTERR_BADCTSTATE;

	if (ct->p.pid > 0) {
		ret = libct_process_wait(&ct->p.h, &status);
		if (ret < 0)
			return -1;
	}

	fs_umount(ct);
	cgroups_destroy(ct); /* FIXME -- can be held accross restarts */
	net_stop(ct);

	ct->state = CT_STOPPED;
	return 0;
}
示例#6
0
文件: ct.c 项目: mkatkar/libct
static ct_process_t __local_spawn_cb(ct_handler_t h, ct_process_desc_t ph, int (*cb)(void *), void *arg, bool is_exec)
{
	struct container *ct = cth2ct(h);
	struct process_desc *p = prh2pr(ph);
	int ret = -1, pid, aux;
	struct ct_clone_arg ca;

	if (ct->state != CT_STOPPED)
		return ERR_PTR(-LCTERR_BADCTSTATE);

	ret = fs_mount(ct);
	if (ret)
		return ERR_PTR(ret);

	if ((ct->flags & CT_KILLABLE) && !(ct->nsmask & CLONE_NEWPID)) {
		if (add_service_controller(ct))
			goto err_cg;
	}

	ret = cgroups_create(ct);
	if (ret)
		goto err_cg;

	ret = -1;
	if (pipe(ca.child_wait_pipe))
		goto err_pipe;
	if (pipe(ca.parent_wait_pipe))
		goto err_pipe2;

	ca.cb = cb;
	ca.arg = arg;
	ca.ct = ct;
	ca.p = p;
	ca.is_exec = is_exec;
	pid = clone(ct_clone, &ca.stack_ptr, ct->nsmask | SIGCHLD, &ca);
	if (pid < 0)
		goto err_clone;

	ct->p.pid = pid;

	close(ca.child_wait_pipe[0]);
	close(ca.parent_wait_pipe[1]);

	if (ct->nsmask & CLONE_NEWUSER) {
		if (write_id_mappings(pid, &ct->uid_map, "uid_map"))
			goto err_net;

		if (write_id_mappings(pid, &ct->gid_map, "gid_map"))
			goto err_net;
	}

	if (net_start(ct))
		goto err_net;

	spawn_wake_and_close(ca.child_wait_pipe, 0);

	aux = spawn_wait(ca.parent_wait_pipe);
	if (aux != 0) {
		ret = aux;
		goto err_ch;
	}

	aux = spawn_wait_and_close(ca.parent_wait_pipe);
	if (aux != INT_MIN) {
		ret = -1;
		goto err_ch;
	}

	ct->state = CT_RUNNING;
	return &ct->p.h;

err_ch:
	net_stop(ct);
err_net:
	spawn_wake_and_close(ca.child_wait_pipe, -1);
	libct_process_wait(&ct->p.h, NULL);
err_clone:
	close(ca.parent_wait_pipe[0]);
	close(ca.parent_wait_pipe[1]);
err_pipe2:
	close(ca.child_wait_pipe[0]);
	close(ca.child_wait_pipe[1]);
err_pipe:
	cgroups_destroy(ct);
err_cg:
	fs_umount(ct);
	return ERR_PTR(ret);
}
示例#7
-1
/* service_main */
static VOID WINAPI service_main(DWORD argc, LPTSTR *argv) {
    config_t        conf;
    void*           net;
    void*           threads;
    void*           pipe;

    h_service = RegisterServiceCtrlHandler(LDMSVC_SERVICE_NAME, handler);
    if(h_service == NULL) {
        return;
    }

    set_state1(SERVICE_START_PENDING);        // SERVICE_START_PENDING

    // open the heap
    if(!heap_start()) {
        dout("Failed to create the heap\n");
        set_state2(SERVICE_STOPPED, 1);
        return;
    }

    // parse configuration
    if(!config_parse_args(&conf, argc, argv)) {
        heap_stop();
        set_state2(SERVICE_STOPPED, 1);
        return;
    }

    if(0) {
        dout(va("PORT: %u\n", conf.port));
        dout(va("PIPE: %s\n", conf.pipe));
        dout(va("MAXC: %u\n", conf.maxconn));
    }

    // open network
    if((net = net_start()) == NULL) {
        heap_stop();
        set_state2(SERVICE_STOPPED, 1);
        return;
    }

    // open the pipe
    if((pipe = pipe_start(conf.pipe)) == NULL) {
        net_stop(net);
        heap_stop();
        set_state2(SERVICE_STOPPED, 1);
        return;
    }

    // connect the pipe
    if(!pipe_open(pipe)) {
        pipe_stop(pipe);
        net_stop(net);
        heap_stop();
        set_state2(SERVICE_STOPPED, 1);
        return;
    }

    // start threads
    if((threads = threads_start(net, pipe, conf.maxconn)) == NULL) {
        pipe_stop(pipe);
        net_stop(net);
        heap_stop();
        set_state2(SERVICE_STOPPED, 1);
        return;
    }

    set_state1(SERVICE_RUNNING);              // SERVICE_RUNNING

    while(svc_state == SERVICE_RUNNING) {
        if(!net_is_ready(net)) {
            net_bind(net, NULL, conf.port);
        }

        if(!threads_think(threads)) {
            break;
        }

        Sleep(1);
    }

    set_state1(SERVICE_STOP_PENDING);         // SERVICE_STOP_PENDING

    // close everything here
    threads_stop(threads);
    pipe_stop(pipe);
    net_stop(net);
    heap_stop();

    set_state2(SERVICE_STOPPED, 0);           // SERVICE_STOPPED
}