当前位置: 首页>>代码示例>>C++>>正文


C++ signal_set函数代码示例

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


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

示例1: maildrop_setup

pid_t
maildrop_setup(uint32_t session_id, int pair[2], struct passwd *pw)
{
	struct imsgev		iev_session;
	struct event		ev_sigint, ev_sigterm;
	struct m_backend	*mb;
	pid_t			pid;
	extern int		mtype;

	if ((pid = fork()) != 0)
		return (pid);

	if (setgroups(1, &pw->pw_gid) ||
	    setresgid(pw->pw_gid, pw->pw_gid, pw->pw_gid) ||
	    setresuid(pw->pw_uid, pw->pw_uid, pw->pw_uid))
		fatal("cannot drop privileges");

	close(pair[0]);
	setproctitle("maildrop");
	if ((mb = m_backend_lookup(mtype)) == NULL)
		fatalx("maildrop: invalid backend");

	event_init();
	signal_set(&ev_sigint, SIGINT, sig_handler, NULL);
	signal_set(&ev_sigterm, SIGTERM, sig_handler, NULL);
	signal_add(&ev_sigint, NULL);
	signal_add(&ev_sigterm, NULL);
	imsgev_init(&iev_session, pair[1], mb, session_imsgev, needfd);
	if (event_dispatch() < 0)
		fatal("event_dispatch");

	logit(LOG_INFO, "%zu: maildrop process exiting", session_id);
	_exit(0);
}
开发者ID:jturner,项目名称:pop3d,代码行数:34,代码来源:maildrop.c

示例2: child

static int child( euca_opts *args, java_home_t *data, uid_t uid, gid_t gid ) {
	int ret = 0;
    jboolean r=0;
	__write_pid( GETARG(args,pidfile) );
	setpgrp( );
	__die(java_init( args, data ) != 1, "Failed to initialize Eucalyptus.");
    __die((r=(*env)->CallBooleanMethod(env,bootstrap.instance,bootstrap.init))==0,"Failed to init Eucalyptus.");
	__abort(4, set_keys_ownership( GETARG( args, home ), uid, gid ) != 0,"Setting ownership of keyfile failed." );
	__abort(4, linuxset_user_group( GETARG( args, user ), uid, gid ) != 0,"Setting the user failed." );
	__abort(4, (set_caps(0)!=0), "set_caps (0) failed");
    __die((r=(*env)->CallBooleanMethod(env,bootstrap.instance,bootstrap.load))==0,"Failed to load Eucalyptus.");
    __die((r=(*env)->CallBooleanMethod(env,bootstrap.instance,bootstrap.start))==0,"Failed to start Eucalyptus.");
	handle._hup = signal_set( SIGHUP, handler );
	handle._term = signal_set( SIGTERM, handler );
	handle._int = signal_set( SIGINT, handler );
	child_pid = getpid( );
	__debug( "Waiting for a signal to be delivered" );
	while( !stopping ) sleep( 60 );
	__debug( "Shutdown or reload requested: exiting" );
    __die((r=(*env)->CallBooleanMethod(env,bootstrap.instance,bootstrap.stop))==0,"Failed to stop Eucalyptus.");
	if( doreload == 1 ) ret = EUCA_RET_RELOAD;
	else ret = 0;
    __die((r=(*env)->CallBooleanMethod(env,bootstrap.instance,bootstrap.destroy))==0,"Failed to destroy Eucalyptus.");
	__die((JVM_destroy( ret ) != 1), "Failed trying to destroy JVM... bailing out seems like the right thing to do" );
	return ret;
}
开发者ID:1ukash,项目名称:eucalyptus-fork-2.0,代码行数:26,代码来源:eucalyptus-bootstrap.c

示例3: signal_setup

static void signal_setup(void)
{
	static struct event ev_sighup;
	static struct event ev_sigterm;
	static struct event ev_sigint;

	sigset_t set;
	int err;

	/* block SIGPIPE */
	sigemptyset(&set);
	sigaddset(&set, SIGPIPE);
	err = sigprocmask(SIG_BLOCK, &set, NULL);
	if (err < 0)
		fatal_perror("sigprocmask");

	/* catch signals */
	signal_set(&ev_sighup, SIGHUP, handle_sighup, NULL);
	err = signal_add(&ev_sighup, NULL);
	if (err < 0)
		fatal_perror("signal_add");

	signal_set(&ev_sigterm, SIGTERM, handle_sigterm, NULL);
	err = signal_add(&ev_sigterm, NULL);
	if (err < 0)
		fatal_perror("signal_add");

	signal_set(&ev_sigint, SIGINT, handle_sigint, NULL);
	err = signal_add(&ev_sigint, NULL);
	if (err < 0)
		fatal_perror("signal_add");
}
开发者ID:priitkustala,项目名称:skytools-dev,代码行数:32,代码来源:pgqd.c

示例4: luaopen_sys

LUALIB_API int
luaopen_sys (lua_State *L)
{
    luaL_register(L, LUA_SYSLIBNAME, sys_lib);
    createmeta(L);

    luaopen_sys_mem(L);
    luaopen_sys_thread(L);

#ifdef _WIN32
#ifdef _WIN32_WCE
    is_WinNT = 1;
#else
    /* Is Win32 NT platform? */
    {
	OSVERSIONINFO osvi;

	osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
	is_WinNT = (GetVersionEx(&osvi)
	 && osvi.dwPlatformId == VER_PLATFORM_WIN32_NT);
    }
#endif

    luaopen_sys_win32(L);
#else
    /* Ignore sigpipe or it will crash us */
    signal_set(SIGPIPE, SIG_IGN);
    /* To interrupt blocking syscalls */
    signal_set(SYS_SIGINTR, NULL);
#endif
    return 1;
}
开发者ID:richardhundt,项目名称:gaia,代码行数:32,代码来源:luasys.c

示例5: ca

pid_t
ca(void)
{
	pid_t		 pid;
	struct passwd	*pw;
	struct event	 ev_sigint;
	struct event	 ev_sigterm;

	switch (pid = fork()) {
	case -1:
		fatal("ca: cannot fork");
	case 0:
		post_fork(PROC_CA);
		break;
	default:
		return (pid);
	}

	purge_config(PURGE_LISTENERS|PURGE_TABLES|PURGE_RULES);

	if ((pw = getpwnam(SMTPD_USER)) == NULL)
		fatalx("unknown user " SMTPD_USER);

	if (chroot(PATH_CHROOT) == -1)
		fatal("ca: chroot");
	if (chdir("/") == -1)
		fatal("ca: chdir(\"/\")");

	config_process(PROC_CA);

	if (setgroups(1, &pw->pw_gid) ||
	    setresgid(pw->pw_gid, pw->pw_gid, pw->pw_gid) ||
	    setresuid(pw->pw_uid, pw->pw_uid, pw->pw_uid))
		fatal("ca: cannot drop privileges");

	imsg_callback = ca_imsg;
	event_init();

	signal_set(&ev_sigint, SIGINT, ca_sig_handler, NULL);
	signal_set(&ev_sigterm, SIGTERM, ca_sig_handler, NULL);
	signal_add(&ev_sigint, NULL);
	signal_add(&ev_sigterm, NULL);
	signal(SIGPIPE, SIG_IGN);
	signal(SIGHUP, SIG_IGN);

	config_peer(PROC_CONTROL);
	config_peer(PROC_PARENT);
	config_peer(PROC_PONY);
	config_done();

	/* Ignore them until we get our config */
	mproc_disable(p_pony);

	if (event_dispatch() < 0)
		fatal("event_dispatch");
	ca_shutdown();

	return (0);
}
开发者ID:nmandery,项目名称:deb-opensmtpd,代码行数:59,代码来源:ca.c

示例6: signal_init

/* Initialize signal handler */
void
signal_init(void)
{
	signal_handler_init();
	signal_set(SIGHUP, sighup, NULL);
	signal_set(SIGINT, sigend, NULL);
	signal_set(SIGTERM, sigend, NULL);
	signal_ignore(SIGPIPE);
}
开发者ID:coraltech,项目名称:keepalived,代码行数:10,代码来源:main.c

示例7: ypldap_dns

pid_t
ypldap_dns(int pipe_ntp[2], struct passwd *pw)
{
	pid_t			 pid;
	struct event	 ev_sigint;
	struct event	 ev_sigterm;
	struct event	 ev_sighup;
	struct env	 env;

	switch (pid = fork()) {
	case -1:
		fatal("cannot fork");
		break;
	case 0:
		break;
	default:
		return (pid);
	}

	setproctitle("dns engine");
	close(pipe_ntp[0]);

	if (setgroups(1, &pw->pw_gid) ||
	    setresgid(pw->pw_gid, pw->pw_gid, pw->pw_gid) ||
	    setresuid(pw->pw_uid, pw->pw_uid, pw->pw_uid))
		fatal("can't drop privileges");
	endservent();

	if (pledge("stdio dns", NULL) == -1)
		fatal("pledge");

	event_init();
	signal_set(&ev_sigint, SIGINT, dns_sig_handler, NULL);
	signal_set(&ev_sigterm, SIGTERM, dns_sig_handler, NULL);
	signal_set(&ev_sighup, SIGHUP, dns_sig_handler, NULL);
	signal_add(&ev_sigint, NULL);
	signal_add(&ev_sigterm, NULL);
	signal_add(&ev_sighup, NULL);

	if ((env.sc_iev = calloc(1, sizeof(*env.sc_iev))) == NULL)
		fatal(NULL);

	env.sc_iev->events = EV_READ;
	env.sc_iev->data = &env;
	imsg_init(&env.sc_iev->ibuf, pipe_ntp[1]);
	env.sc_iev->handler = dns_dispatch_imsg;
	event_set(&env.sc_iev->ev, env.sc_iev->ibuf.fd, env.sc_iev->events,
	    env.sc_iev->handler, &env);
	event_add(&env.sc_iev->ev, NULL);

	event_dispatch();
	dns_shutdown();

	return (0);
}
开发者ID:ajinkya93,项目名称:OpenBSD,代码行数:55,代码来源:ypldap_dns.c

示例8: reload_vrrp_thread

/* Reload thread */
int
reload_vrrp_thread(thread * thread_obj)
{
	/* set the reloading flag */
	SET_RELOAD;
    SYS_VRRP_LOG_INFO("VRRP configure have been reload.");

	/* Close sockpool */
	free_vrrp_sockpool(vrrp_data);

	/* Signal handling */
	signal_reset();
	signal_set(SIGHUP, sighup_vrrp, NULL);
	signal_set(SIGINT, sigend_vrrp, NULL);
	signal_set(SIGTERM, sigend_vrrp, NULL);
	signal_ignore(SIGPIPE);

	/* Destroy master thread */
	thread_destroy_master(master);
	master = thread_make_master();
	free_global_data(data);
	/* add by zhouben */
	backup_if_queue();
	kernel_netlink_close();
	free_vrrp_buffer();
	gratuitous_arp_close();
	ndisc_close();
	vrrp_trackip_close();

	/* Save previous conf data */
	old_vrrp_data = vrrp_data;
	vrrp_data = NULL;

#ifdef _WITH_LVS_
	/* Clean ipvs related */
	//ipvs_stop();
#endif

	/* Reload the conf */
	mem_allocated = 0;
	vrrp_signal_init();
	signal_set(SIGCHLD, thread_child_handler, master);
	start_vrrp();

	/* free backup data */
	free_old_interface_queue_only();
	free_vrrp_data(old_vrrp_data);
	UNSET_RELOAD;

       /*end of reload, store the state to file*/
       reloading = 0;
       vrrp_state_store();
	return 0;
}
开发者ID:millken,项目名称:zhuxianB30,代码行数:55,代码来源:vrrp_daemon.c

示例9: vrrp_signal_init

/* VRRP Child signal handling */
void
vrrp_signal_init(void)
{
	signal_handler_init();
	signal_set(SIGHUP, sighup_vrrp, NULL);
	signal_set(SIGINT, sigend_vrrp, NULL);
	signal_set(SIGTERM, sigend_vrrp, NULL);
	signal_set(SIGUSR1, sigusr1_vrrp, NULL);
	signal_set(SIGUSR2, sigusr2_vrrp, NULL);
	signal_ignore(SIGPIPE);
}
开发者ID:vrit,项目名称:keepalived,代码行数:12,代码来源:vrrp_daemon.c

示例10: signal_init

/* Initialize signal handler */
void
signal_init(void)
{
	signal_handler_init();
	signal_set(SIGHUP, propogate_signal, NULL);
	signal_set(SIGUSR1, propogate_signal, NULL);
	signal_set(SIGUSR2, propogate_signal, NULL);
	signal_set(SIGINT, sigend, NULL);
	signal_set(SIGTERM, sigend, NULL);
	signal_ignore(SIGPIPE);
}
开发者ID:LouisRenWeiWei,项目名称:keepalived,代码行数:12,代码来源:main.c

示例11: client_main

__dead void
client_main(void)
{
	struct event		ev_sigcont, ev_sigterm, ev_sigwinch;
	struct sigaction	sigact;

	logfile("client");

	/* Note: event_init() has already been called. */

	/* Set up signals. */
	memset(&sigact, 0, sizeof sigact);
	sigemptyset(&sigact.sa_mask);
	sigact.sa_flags = SA_RESTART;
	sigact.sa_handler = SIG_IGN;
	if (sigaction(SIGINT, &sigact, NULL) != 0)
		fatal("sigaction failed");
	if (sigaction(SIGPIPE, &sigact, NULL) != 0)
		fatal("sigaction failed");
	if (sigaction(SIGUSR1, &sigact, NULL) != 0)
		fatal("sigaction failed");
	if (sigaction(SIGUSR2, &sigact, NULL) != 0)
		fatal("sigaction failed");
	if (sigaction(SIGTSTP, &sigact, NULL) != 0)
		fatal("sigaction failed");

	signal_set(&ev_sigcont, SIGCONT, client_signal, NULL);
	signal_add(&ev_sigcont, NULL);
	signal_set(&ev_sigterm, SIGTERM, client_signal, NULL);
	signal_add(&ev_sigterm, NULL);
	signal_set(&ev_sigwinch, SIGWINCH, client_signal, NULL);
	signal_add(&ev_sigwinch, NULL);

	/*
	 * imsg_read in the first client poll loop (before the terminal has
	 * been initialised) may have read messages into the buffer after the
	 * MSG_READY switched to here. Process anything outstanding now to
	 * avoid hanging waiting for messages that have already arrived.
	 */
	if (client_dispatch() != 0)
		goto out;

	/* Set the event and dispatch. */
	client_update_event();
	event_dispatch();

out:
	/* Print the exit message, if any, and exit. */
	if (client_exitmsg != NULL && !login_shell)
		printf("[%s]\n", client_exitmsg);
	exit(client_exitval);
}
开发者ID:ThomasAdam,项目名称:tmux-ARCHIVED,代码行数:52,代码来源:client.c

示例12: signal_init

EVQ_API void
signal_init (void)
{
  if (g_SignalInit) return;
  g_SignalInit = 1;

  /* Initialize critical section */
  pthread_mutex_init(&g_Signal.cs, NULL);
  /* Ignore sigpipe or it will crash us */
  signal_set(SIGPIPE, SIG_IGN);
  /* To interrupt blocking syscalls */
  signal_set(SYS_SIGINTR, signal_handler);
}
开发者ID:richardhundt,项目名称:luasys,代码行数:13,代码来源:signal.c

示例13: signal_init

/* Initialize signal handlers. */
void
signal_init(void) {
  signal_set(SIGINT,   sigint);
  signal_set(SIGTSTP,  sigtstp);
  signal_set(SIGALRM,  sigalarm);
  signal_set(SIGPIPE,  SIG_IGN);
  signal_set(SIGQUIT,  SIG_IGN);
  signal_set(SIGTTIN,  SIG_IGN);
  signal_set(SIGTTOU,  SIG_IGN);
  signal_set(SIGTERM,  sigterm);
  signal_set(SIGHUP,   SIG_IGN);
  signal_set(SIGWINCH, sigwinch);
}
开发者ID:AkiraSuu,项目名称:lagopus,代码行数:14,代码来源:signals.c

示例14: signal_del

static int
signal_del (struct event_queue *evq, struct event *ev)
{
  const int signo = (ev->flags & EVENT_PID) ? EVQ_SIGCHLD
   : (int) ev->fd;
  struct event **sig_evp = signal_gethead(signo);
  int res = 0;

  pthread_mutex_lock(&g_Signal.cs);
  if (*sig_evp == ev) {
    if (!(*sig_evp = ev->next_object)) {
#ifndef USE_KQUEUE
      (void) evq;
#else
      res |= signal_kqueue(evq, signo, EV_DELETE);
#endif
      res |= signal_set(signo, SIG_DFL);
    }
  } else {
    struct event *sig_ev = *sig_evp;

    while (sig_ev->next_object != ev)
      sig_ev = sig_ev->next_object;
    sig_ev->next_object = ev->next_object;
  }
  pthread_mutex_unlock(&g_Signal.cs);
  return res;
}
开发者ID:richardhundt,项目名称:luasys,代码行数:28,代码来源:signal.c

示例15: signal_add

static int
signal_add (struct event_queue *evq, struct event *ev)
{
  const int signo = (ev->flags & EVENT_PID) ? EVQ_SIGCHLD : (int) ev->fd;
  struct event **sig_evp = signal_gethead(signo);

  if (!sig_evp) return -1;

  pthread_mutex_lock(&g_Signal.cs);
  if (*sig_evp)
    ev->next_object = *sig_evp;
  else {
#ifdef USE_KQUEUE
    if (signal_kqueue(evq, signo, EV_ADD))
      goto err;
#endif
    if (signal_set(signo, signal_handler))
      goto err;
    ev->next_object = NULL;
  }
  *sig_evp = ev;
  pthread_mutex_unlock(&g_Signal.cs);

  evq->nevents++;
  return 0;
 err:
  pthread_mutex_unlock(&g_Signal.cs);
  return -1;
}
开发者ID:richardhundt,项目名称:luasys,代码行数:29,代码来源:signal.c


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