• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ signal_init函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中signal_init函数的典型用法代码示例。如果您正苦于以下问题:C++ signal_init函数的具体用法?C++ signal_init怎么用?C++ signal_init使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了signal_init函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: main

/* Entry point */
int
main(int argc, char **argv)
{
	/* Init debugging level */
	mem_allocated = 0;
	debug = 0;

	/*
	 * Parse command line and set debug level.
	 * bits 0..7 reserved by main.c
	 */
	parse_cmdline(argc, argv);

	openlog(PROG, LOG_PID | ((debug & 1) ? LOG_CONS : 0), log_facility);
	log_message(LOG_INFO, "Starting " VERSION_STRING);

	/* Check if keepalived is already running */
	if (keepalived_running(daemon_mode)) {
		log_message(LOG_INFO, "daemon is already running");
		goto end;
	}

	if (debug & 1)
		enable_console_log();

	/* daemonize process */
	if (!(debug & 2))
		xdaemon(0, 0, 0);

	/* write the father's pidfile */
	if (!pidfile_write(main_pidfile, getpid()))
		goto end;

#ifndef _DEBUG_
	/* Signal handling initialization  */
	signal_init();
#endif

	/* Create the master thread */
	master = thread_make_master();

	/* Init daemon */
	start_keepalived();

#ifndef _DEBUG_
	/* Launch the scheduling I/O multiplexer */
	launch_scheduler();

	/* Finish daemon process */
	stop_keepalived();
#endif

	/*
	 * Reached when terminate signal catched.
	 * finally return from system
	 */
end:
	closelog();
	exit(0);
}
开发者ID:coraltech,项目名称:keepalived,代码行数:61,代码来源:main.c


示例2: dn_pre_run

static rstatus_t
dn_pre_run(struct instance *nci)
{
    rstatus_t status;

    status = log_init(nci->log_level, nci->log_filename);
    if (status != DN_OK) {
        return status;
    }

    if (daemonize) {
        status = dn_daemonize(1);
        if (status != DN_OK) {
            return status;
        }
    }

    nci->pid = getpid();

    status = signal_init();
    if (status != DN_OK) {
        return status;
    }

    if (nci->pid_filename) {
        status = dn_create_pidfile(nci);
        if (status != DN_OK) {
            return status;
        }
    }

    dn_print_run(nci);

    return DN_OK;
}
开发者ID:dprof,项目名称:dprof244b,代码行数:35,代码来源:dynomite.c


示例3: main

int main(int argc, char **argv) {
    if (-1 == check_para(argc, argv)) {
        PRINTF(LEVEL_ERROR, "check argument error.\n");
        return -1;
    }

    signal_init();

    PRINTF(LEVEL_INFORM, "socks5 starting, port: %d\n", g_cfg.port);

    g_cfg.fd = socks5_srv_init(g_cfg.port, 10);
    if (-1 == g_cfg.fd) {
        PRINTF(LEVEL_ERROR, "socks server init error.\n");
        return -1;
    }

    g_cfg.state = SOCKS5_STATE_RUNNING;

    g_loop = ev_default_loop(0);

    ev_io_init(&g_io_accept, accept_cb, g_cfg.fd, EV_READ);
    ev_io_start(g_loop, &g_io_accept);

    ev_loop(g_loop, 0);

    PRINTF(LEVEL_INFORM, "time to exit.\n");
    socks5_srv_exit();
    PRINTF(LEVEL_INFORM, "exit socket server.\n");
    return 0;
}
开发者ID:ecore2018,项目名称:socks5-1,代码行数:30,代码来源:socks5.c


示例4: silly_run

void
silly_run(struct silly_config *config)
{
	int i;
	int err;
	pthread_t pid[3];
	R.run = 1;
	R.exit = 0;
	pthread_mutex_init(&R.mutex, NULL); 
	pthread_cond_init(&R.cond, NULL);
	if (config->daemon)
		silly_daemon(config);
	signal_init();
	silly_timer_init();
	err = silly_socket_init();
	if (err < 0) {
		fprintf(stderr, "%s socket init fail:%d\n", config->selfname, err);
		exit(-1);
	}
	silly_worker_init();
	srand(time(NULL));
	thread_create(&pid[0], thread_socket, NULL);
	thread_create(&pid[1], thread_timer, NULL);
	thread_create(&pid[2], thread_worker, config);
	fprintf(stdout, "%s is running ...\n", config->selfname);
	for (i = 0; i < 3; i++)
		pthread_join(pid[i], NULL);
	pthread_mutex_destroy(&R.mutex);
	pthread_cond_destroy(&R.cond);
	silly_worker_exit();
	silly_timer_exit();
	silly_socket_exit();
	fprintf(stdout, "%s has already exit...\n", config->selfname);
	return ;
}
开发者ID:findstr,项目名称:silly,代码行数:35,代码来源:silly_run.c


示例5: test_signal_handler

static int test_signal_handler(const char *argv0, const char *tempdir, int sig)
{
	int ret, pid, status;
	char err[512] = { 0 };
	char crash_log_path[PATH_MAX];
	snprintf(crash_log_path, sizeof(crash_log_path), "%s/crash.log.%d",
		 tempdir, rand());
	pid = fork();
	if (pid == -1) {
		ret = errno;
		return ret;
	}
	else if (pid == 0) {
		struct logc lc;
		memset(&lc, 0, sizeof(lc));
		lc.crash_log_path = crash_log_path;
		signal_init(argv0, err, sizeof(err), &lc);
		if (err[0]) {
			fprintf(stderr, "signal_init error: %s\n", err);
			_exit(1);
		}
		raise(sig);
		_exit(1);
	}
	RETRY_ON_EINTR(ret, waitpid(pid, &status, 0));

	EXPECT_ZERO(validate_crash_log(crash_log_path, sig));
	return 0;
}
开发者ID:cmccabe,项目名称:redfish,代码行数:29,代码来源:signal_unit.c


示例6: signal_init

void sdl_application::execute(window& win)
{
	signal_init();

	SDL_GL_SetSwapInterval(1);

#ifdef EMSCRIPTEN

	emscripten_set_main_loop_arg(update_c_function, this, -1, 1);

#else

	SDL_GL_SetSwapInterval(0);

	while (running)
	{
		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
		update_c_function(this);
		SDL_GL_SwapWindow(win.m_window);
	}

#endif

	signal_quit();
}
开发者ID:sutirthaghosh,项目名称:gentlemanly_engine,代码行数:25,代码来源:sdl_application.cpp


示例7: mshell_init

int mshell_init(struct mshell *mshell, int argc, char **argv, char **env)
{
	memset(mshell, 0, sizeof(struct mshell));
	mshell->user = getpwuid(getuid());
	mshell->main_loop = 1;
	mshell->is_show_cmdline = 1;
	getcwd(mshell->cur_dir, PATH_MAX);
	mshell->fd = 0;
	mshell->pipe = -1;
	mshell->wait_for_childs = 0;

	/*需要执行脚本*/
	if(argc >= 2) {
		mshell->fd = open(argv[1], O_RDONLY);
		if(mshell->fd < 0) {
			mshell->main_loop = 0;
			perror("open");
			return 0;
		}
		mshell->is_show_cmdline = 0;
	}

	signal_init();
	load_env(mshell, env);
	return 0;
}
开发者ID:chenyuwen,项目名称:mshell,代码行数:26,代码来源:mshell.c


示例8: main

int
main(int argc, char **argv)
{
	thread thread_obj;

	/* Allocate the room */
	req = (REQ *) MALLOC(sizeof (REQ));

	/* Command line parser */
	if (!parse_cmdline(argc, argv, req)) {
		FREE(req);
		exit(0);
	}

	/* Check minimum configuration need */
	if (!req->addr_ip && !req->addr_port && !req->url) {
		FREE(req);
		exit(0);
	}

	/* Init the reference timer */
	req->ref_time = timer_tol(timer_now());
	DBG("Reference timer = %lu\n", req->ref_time);

	/* Init SSL context */
	init_ssl();

	/* Signal handling initialization  */
	signal_init();

	/* Create the master thread */
	master = thread_make_master();

	/* Register the GET request */
	init_sock();

	/*
	 * Processing the master thread queues,
	 * return and execute one ready thread.
	 * Run until error, used for debuging only.
	 * Note that not calling launch_scheduler() does
	 * not activate SIGCHLD handling, however, this
	 * is no issue here.
	 */
	while (thread_fetch(master, &thread_obj))
		thread_call(&thread_obj);

	/* Finalize output informations */
	if (req->verbose)
		printf("Global response time for [%s] =%lu\n",
		       req->url, req->response_time - req->ref_time);

	/* exit cleanly */
	SSL_CTX_free(req->ctx);
	free_sock(sock);
	FREE(req);
	exit(0);
}
开发者ID:millken,项目名称:zhuxianB30,代码行数:58,代码来源:main.c


示例9: main

int			main()
{
  struct sigaction	*act;

  if (!(act = act_init(act)))
    my_error(4, 6);
  signal_init(act);
  print_pid(getpid());
  call_next_client(getpid());
}
开发者ID:mockingbirdnj83,项目名称:minitalk,代码行数:10,代码来源:main.c


示例10: init_subsystems

static void init_subsystems()
{
	shared_init();
	heap_init();
	signal_init();
	process_init();
	tls_init();
	vfs_init();
	dbt_init();
}
开发者ID:AnXi-TieGuanYin-Tea,项目名称:flinux,代码行数:10,代码来源:main.c


示例11: thread_dup

error_t thread_dup(struct task_s *task,
                   struct thread_s *dst,
                   struct cpu_s *dst_cpu,
                   struct cluster_s *dst_clstr,
                   struct thread_s *src)
{
    register uint_t sched_policy;
    register uint_t cpu_lid;
    register uint_t cid;
    struct page_s *page;

    sched_policy = sched_getpolicy(src);
    cpu_lid      = dst_cpu->lid;
    cid          = dst_clstr->id;
    page         = dst->info.page;

    // Duplicate
    page_copy(page, src->info.page);

    // Initialize dst thread
    spinlock_init(&dst->lock, "Thread");
    dst->flags                           = 0;
    thread_clear_joinable(dst);
    dst->locks_count                     = 0;
    dst->ticks_nr                        = 0;
    thread_set_current_cpu(dst, dst_cpu);
    sched_setpolicy(dst, sched_policy);
    dst->task                            = task;
    dst->type                            = PTHREAD;
    dst->info.sched_nr                   = 0;
    dst->info.ppm_last_cid               = cid;
    dst->info.migration_cntr             = 0;
    dst->info.migration_fail_cntr        = 0;
    dst->info.tm_exec                    = 0;
    dst->info.tm_tmp                     = 0;
    dst->info.tm_usr                     = 0;
    dst->info.tm_sys                     = 0;
    dst->info.tm_sleep                   = 0;
    dst->info.tm_wait                    = 0;
    signal_init(dst);
    dst->info.join                       = NULL;
    wait_queue_init(&dst->info.wait_queue, "Join/Exit Sync");
    dst->info.attr.sched_policy          = sched_policy;
    dst->info.attr.cid                   = cid;
    dst->info.attr.cpu_lid               = cpu_lid;
    dst->info.attr.cpu_gid               = dst_cpu->gid;
    dst->info.attr.tid                   = (uint_t) dst;
    dst->info.attr.pid                   = task->pid;
    dst->info.kstack_addr                = (uint_t*)dst;
    dst->info.page                       = page;
    dst->signature                       = THREAD_ID;

    return 0;
}
开发者ID:walafc0,项目名称:almos-mk,代码行数:54,代码来源:thread_dup.c


示例12: init

static void init() {

    int initialized = protocol_init() && caps_init() && signal_init() && comm_init() && injectable_init();
    
    if (!initialized) {
        fatal("Initialization failed.");
        cleanup();
        exit(EXIT_FAILURE);
    }
    
}
开发者ID:Jarlene,项目名称:ADBI-1,代码行数:11,代码来源:adbiserver.c


示例13: main

int main()
{
	int fd;
	char buf[MAX_MSG_LEN] = {0};
	char client_name[128] = {0};
	pid_t pid;

	signal_init();
	
	sprintf(client_name, "%05d.socket", getpid());

	fd = client_conn(SERVER_IPC_DOMAIN_NAME, client_name);

	pid = fork();

	if (pid < 0)
	{
		DEBUG_ERR("fork error\n");
	}
	else if (pid == 0)
	{
		sprintf(client_name, "%05d.socket", getpid());
		fd = client_conn(SERVER_IPC_DOMAIN_NAME, client_name);
		if (fd < 0)
		{
			DEBUG_ERR("create server unix domain socket error\n");
			return -1;
		}

		memset(buf, 0 ,sizeof(buf));
		sprintf(buf, "client_name %s", client_name);
		write(fd, buf, sizeof(buf));

		close(fd);
		unlink(client_name);

		exit(0);
	}
	
	if (fd < 0)
	{
		DEBUG_ERR("create server unix domain socket error\n");
		return -1;
	}

	sprintf(buf, "client_name %s", client_name);
	swriten(fd, buf, sizeof(buf));

	close(fd);
	unlink(client_name);
	
	return 0;
}
开发者ID:lyj496332184,项目名称:cfg_ipc,代码行数:53,代码来源:cfg_ipc_client.c


示例14: event_init

void event_init()
{
  // Initialize input events
  input_init();
  // Timer to wake the event loop if a timeout argument is passed to
  // `event_poll`
  // Signals
  signal_init();
  uv_timer_init(uv_default_loop(), &timer);
  // This prepare handle that actually starts the timer
  uv_prepare_init(uv_default_loop(), &timer_prepare);
}
开发者ID:fofore,项目名称:neovim,代码行数:12,代码来源:event.c


示例15: main

int
main(int argc, char * const argv[])
{
	int c;
	boolean_t fork = B_TRUE;

	progname = basename(strdup(argv[0]));

	if ((fmri = (const char *)getenv("SMF_FMRI")) == NULL)
		fmri = DEFAULT_FMRI;

	(void) setlocale(LC_ALL, "");
#if !defined(TEXT_DOMAIN)
#define	TEXT_DOMAIN "SYS_TEST"
#endif
	(void) textdomain(TEXT_DOMAIN);

	while ((c = getopt(argc, argv, "djn")) != EOF) {
		switch (c) {
		case 'd':
			dlevel = 0xffff;
			break;
		case 'j':
			json = B_TRUE;
			break;
		case 'n':
			fork = B_FALSE;
			break;
		default:
			(void) fprintf(stderr, gettext("Unknown option "
			    "\'%c\'.\n"), c);
			usage(progname);
		}
	}

	pid = getpid();

	if ((main_port = port_create()) == -1)
		err(EXIT_FAILURE, "port_create() failed");

	list_create(&links, sizeof (link_t), offsetof(link_t, node));

	VERIFY(get_sysinfo());
	lldp_read_config();
	signal_init();
	get_port_list();
	lldp_init(4);
	cdp_init(4);
	main_loop();

	return (0);
}
开发者ID:jasonbking,项目名称:lldp,代码行数:52,代码来源:lldd.c


示例16: ex_init

/*
 * Initialize whatever we need
 * for dealing with external processes
 */
void
ex_init(void) {
	keytab_init();
	well_known_init();
	signal_init();

	historyfile = getenv("HISTORY");
	if(!historyfile)
		historyfile = getenv("history");

	shell =  getenv("SHELL");
	if(!shell)
		shell=DEFAULTSHELL;
}
开发者ID:knusbaum,项目名称:Wily,代码行数:18,代码来源:exec.c


示例17: core_init

// Init BSP-core
int core_init()
{
    if (!core_settings.initialized)
    {
        init_core_setting();
    }

    if (core_settings.is_daemonize)
    {
        proc_daemonize();
    }

    fd_init(0);
    log_init();
    load_runtime_setting();
    status_op_core(STATUS_OP_INSTANCE_ID, (size_t) core_settings.instance_id);
    thread_init();
    save_pid();
    signal_init();
    socket_init();
    memdb_init();
    online_init();

    // Load modules
    BSP_VALUE *val = object_get_hash_str(runtime_settings, "modules");
    BSP_OBJECT *vobj = value_get_object(val);
    BSP_STRING *vstr = NULL;
    if (vobj && OBJECT_TYPE_ARRAY == vobj->type)
    {
        size_t varr_size = object_size(vobj), i;
        if (varr_size > MAX_MODULES)
        {
            varr_size = MAX_MODULES;
        }

        reset_object(vobj);
        for (i = 0; i < varr_size; i ++)
        {
            val = object_get_array(vobj, i);
            vstr = value_get_string(val);
            if (vstr)
            {
                script_load_module(vstr, 1);
            }
        }
    }

    return BSP_RTN_SUCCESS;
}
开发者ID:shenzhe,项目名称:bsp,代码行数:50,代码来源:core.c


示例18: main

int
main (void)
{
  master = thread_master_create ();
  signal_init (master, array_size(sigs), sigs);
  
  zlog_default = openzlog("testsig", ZLOG_NONE,
                          LOG_CONS|LOG_NDELAY|LOG_PID, LOG_DAEMON);
  zlog_set_level (NULL, ZLOG_DEST_SYSLOG, ZLOG_DISABLED);
  zlog_set_level (NULL, ZLOG_DEST_STDOUT, LOG_DEBUG);
  zlog_set_level (NULL, ZLOG_DEST_MONITOR, ZLOG_DISABLED);
  
  while (thread_fetch (master, &t))
    thread_call (&t);

  exit (0);
}
开发者ID:AsherBond,项目名称:quagga,代码行数:17,代码来源:test-sig.c


示例19: process_ctx_init_impl

static int process_ctx_init_impl(const char *argv0, int daemonize,
				struct logc *lc)
{
	char err[512] = { 0 };
	size_t err_len = sizeof(err);

	configure_glitch_log(lc);
	g_fast_log_mgr = fast_log_mgr_init(g_fast_log_dumpers);
	if (IS_ERR(g_fast_log_mgr)) {
		glitch_log("fast_log_mgr_init failed with error %d",
			PTR_ERR(g_fast_log_mgr));
		g_fast_log_mgr = NULL;
		goto error_close_glitchlog;
	}
	if (lc->fast_log == JORM_INVAL_STR)
		configure_fast_log(getenv("REDFISH_LOG"));
	else
		configure_fast_log(lc->fast_log);
	signal_init(argv0, err, err_len, lc);
	if (err[0]) {
		glitch_log("signal_init error: %s\n", err);
		goto error_free_fast_log_mgr;
	}
	if (daemonize) {
		if (daemon(0, 0) < 0) {
			int ret = errno;
			glitch_log("daemon(3) error %d\n", ret);
			goto error_signal_shutdown;
		}
	}
	create_pid_file(lc, err, err_len);
	if (err[0]) {
		glitch_log("create_pid_file error: %s\n", err);
		goto error_signal_shutdown;
	}
	return 0;

error_signal_shutdown:
	signal_shutdown();
error_free_fast_log_mgr:
	fast_log_mgr_release(g_fast_log_mgr);
	g_fast_log_mgr = NULL;
error_close_glitchlog:
	close_glitch_log();
	return 1;
}
开发者ID:cmccabe,项目名称:redfish,代码行数:46,代码来源:process_ctx.c


示例20: main

int main(int argc, char *argv[])
{
    struct sock_t sock;
    struct sock_bind_t sock_bind;
    struct user_param_t *user_param = &(rdma_resource.user_param);

    RDMAParser parser;
    if(!parser.Parse(&(rdma_resource.user_param), argv, argc))
    {
        g_lastErrorCode = IBDT_E_InvalidParam;
        return g_lastErrorCode;
    }

    sock_bind.socket_fd = -1;
    sock_bind.counter = 0;
    sock_bind.is_daemon = (user_param->server_ip == NULL) ? 1 : 0;
    sock_bind.port = user_param->tcp_port;
    if (user_param->server_ip)
    {
        strcpy(sock_bind.ip, user_param->server_ip);
    }

    signal_init();
    RDMASock::sock_init(&sock);

    if(!RDMAResource::InitResource(&sock, &rdma_resource))
    {
        goto cleanup;
    }

    if(!RDMAThread::StartRDMAThreads(&rdma_resource, &sock_bind))
    {
        printf("Testing failed\n");
    }

    while(!stop_all)
    {
        if(!sock_bind.is_daemon)
            break;
    }

cleanup:
    RDMAResource::DestroyResource(&rdma_resource);

    return g_lastErrorCode;
}
开发者ID:passionkk,项目名称:IBDataTransfer,代码行数:46,代码来源:main.cpp



注:本文中的signal_init函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ signal_pending函数代码示例发布时间:2022-05-30
下一篇:
C++ signal_emit函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap