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

C++ signal_set函数代码示例

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

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



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


示例16: sigint

/* SIGINT handler.  This function takes care of ^C input. */
static void
sigint(int signo) {
  /* Debug */
  if (0) {
    printf("signo %d\n", signo);
  }

  /* Reinstall signal. */
  signal_set(SIGINT, sigint);

  /* Wait child process. */
  if (process_list) {
    process_wait_for();
  } else {
    printf("\n");
  }

  /* Make it sure cclient is reset. */
  cclient_stop(shell->cclient);

  /* Long jump flag check. */
  if (! jmpflag) {
    return;
  }

  jmpflag = 0;

  /* Back to main command loop. */
  siglongjmp(jmpbuf, 1);
}
开发者ID:AkiraSuu,项目名称:lagopus,代码行数:31,代码来源:signals.c


示例17: event

void AsyncSignalHandler::registerSignalHandler(int signum) {
  pair<SignalEventMap::iterator, bool> ret =
    signalEvents_.insert(make_pair(signum, event()));
  if (!ret.second) {
    // This signal has already been registered
    throw std::runtime_error(folly::to<string>(
                               "handler already registered for signal ",
                               signum));
  }

  struct event* ev = &(ret.first->second);
  try {
    signal_set(ev, signum, libeventCallback, this);
    if (event_base_set(eventBase_->getLibeventBase(), ev) != 0 ) {
      throw std::runtime_error(folly::to<string>(
                                 "error initializing event handler for signal ",
                                 signum));
    }

    if (event_add(ev, nullptr) != 0) {
      throw std::runtime_error(folly::to<string>(
                                 "error adding event handler for signal ",
                                 signum));
    }
  } catch (...) {
    signalEvents_.erase(ret.first);
    throw;
  }
}
开发者ID:GYGit,项目名称:folly,代码行数:29,代码来源:AsyncSignalHandler.cpp


示例18: signal_init

void
signal_init (struct thread_master *m, int sigc,
             struct quagga_signal_t signals[])
{

    int i = 0;
    struct quagga_signal_t *sig;

    /* First establish some default handlers that can be overridden by
       the application. */
    trap_default_signals();

    while (i < sigc)
    {
        sig = &signals[i];
        if ( signal_set (sig->signal) < 0 ) {
            zlog_notice("signal_init exit(-1)\n");
            EXIT(-1);

        }
        i++;
    }

    sigmaster.sigc = sigc;
    sigmaster.signals = signals;

#ifdef SIGEVENT_SCHEDULE_THREAD
    sigmaster.t =
        thread_add_timer (m, quagga_signal_timer, &sigmaster,
                          QUAGGA_SIGNAL_TIMER_INTERVAL);
#endif /* SIGEVENT_SCHEDULE_THREAD */
}
开发者ID:kkcloudy,项目名称:daemongroup,代码行数:32,代码来源:sigevent.c


示例19: sigtstp

/* SIGTSTP handler.  This function takes care of ^Z input. */
static void
sigtstp(int signo) {
  /* Debug */
  if (0) {
    printf("signo %d\n", signo);
  }

  /* Reinstall signal. */
  signal_set(SIGTSTP, sigtstp);

  /* Do nothing when sub-process is running. */
  if (process_list) {
    return;
  }

  /* New line. */
  printf("\n");

  /* Make it sure cclient is reset. */
  cclient_stop(shell->cclient);

  /* Long jump flag check. */
  if (! jmpflag) {
    return;
  }

  jmpflag = 0;

  /* Back to main command loop. */
  siglongjmp(jmpbuf, 1);
}
开发者ID:AkiraSuu,项目名称:lagopus,代码行数:32,代码来源:signals.c


示例20: proc_set_signals

void
proc_set_signals(struct tmuxproc *tp, void (*signalcb)(int))
{
	struct sigaction	sa;

	tp->signalcb = signalcb;

	memset(&sa, 0, sizeof sa);
	sigemptyset(&sa.sa_mask);
	sa.sa_flags = SA_RESTART;
	sa.sa_handler = SIG_IGN;

	sigaction(SIGINT, &sa, NULL);
	sigaction(SIGPIPE, &sa, NULL);
	sigaction(SIGTSTP, &sa, NULL);

	signal_set(&tp->ev_sighup, SIGHUP, proc_signal_cb, tp);
	signal_add(&tp->ev_sighup, NULL);
	signal_set(&tp->ev_sigchld, SIGCHLD, proc_signal_cb, tp);
	signal_add(&tp->ev_sigchld, NULL);
	signal_set(&tp->ev_sigcont, SIGCONT, proc_signal_cb, tp);
	signal_add(&tp->ev_sigcont, NULL);
	signal_set(&tp->ev_sigterm, SIGTERM, proc_signal_cb, tp);
	signal_add(&tp->ev_sigterm, NULL);
	signal_set(&tp->ev_sigusr1, SIGUSR1, proc_signal_cb, tp);
	signal_add(&tp->ev_sigusr1, NULL);
	signal_set(&tp->ev_sigusr2, SIGUSR2, proc_signal_cb, tp);
	signal_add(&tp->ev_sigusr2, NULL);
	signal_set(&tp->ev_sigwinch, SIGWINCH, proc_signal_cb, tp);
	signal_add(&tp->ev_sigwinch, NULL);
}
开发者ID:SeamusConnor,项目名称:tmux,代码行数:31,代码来源:proc.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ signal_stop函数代码示例发布时间:2022-05-30
下一篇:
C++ signal_pending函数代码示例发布时间: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