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

C++ sigblock函数代码示例

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

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



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

示例1: dplog

void
dplog(const char *fmt, ...)
{
#ifdef HAVE_SIGACTION
  sigset_t old, chld;
#else /* not HAVE_SIGACTION */
  int mask;
#endif /* not HAVE_SIGACTION */
  va_list ap;

#ifdef HAVE_SIGACTION
  sigemptyset(&chld);
  sigaddset(&chld, SIGCHLD);
#else /* not HAVE_SIGACTION */
  mask = sigblock(sigmask(SIGCHLD));
#endif /* not HAVE_SIGACTION */

  sigprocmask(SIG_BLOCK, &chld, &old);
  if (!logfp)
    logfp = stderr;		/* initialize before possible first use */

  va_start(ap, fmt);
  real_plog(XLOG_DEBUG, fmt, ap);
  va_end(ap);

#ifdef HAVE_SIGACTION
  sigprocmask(SIG_SETMASK, &old, NULL);
#else /* not HAVE_SIGACTION */
  mask = sigblock(sigmask(SIGCHLD));
#endif /* not HAVE_SIGACTION */
}
开发者ID:0mp,项目名称:freebsd,代码行数:31,代码来源:xutil.c


示例2: readTimeoutBlocked

int readTimeoutBlocked(int fd,PVStr(buf),int siz,int timeout)
{	int omask,nmask;
	int rcc;
	int serno;
	int serrno;

	alertVStr(buf,siz);
	rcc = -1;
	omask = sigblock(sigmask(SIGCHLD));
	serno = ++readSERNO;
	if( 0 < PollIn(fd,timeout) ){
		errno = 0;
		rcc = read(fd,(char*)buf,QVSSize(buf,siz));
		serrno = errno;
		if( rcc != siz ){
		sv1log("##ERROR: readTimeoutB insufficient read %d/%d (%d)%X\n",
			rcc,siz,errno,sigblock(0));
		}
		errno = serrno;
	}
	if( serno != readSERNO ){
		sv1log("##ERROR: readTimeoutB broken %d/%d (%d)%X\n",
			serno,readSERNO,errno,sigblock(0));
		sleep(10);
	}
	nmask = sigsetmask(omask);
	return rcc;
}
开发者ID:2dot4,项目名称:Psiphon3-for-Linux,代码行数:28,代码来源:iotimeout.c


示例3: tipout

/*
 * ****TIPOUT   TIPOUT****
 */
void
tipout(void)
{
	char buf[BUFSIZ];
	char *cp;
	int cnt;
	int omask;

	signal(SIGINT, SIG_IGN);
	signal(SIGQUIT, SIG_IGN);
	signal(SIGEMT, intEMT);		/* attention from TIPIN */
	signal(SIGTERM, intTERM);	/* time to go signal */
	signal(SIGIOT, intIOT);		/* scripting going on signal */
	signal(SIGHUP, intTERM);	/* for dial-ups */
	signal(SIGSYS, intSYS);		/* beautify toggle */
	(void) setjmp(sigbuf);
	for (omask = 0;; sigsetmask(omask)) {
		cnt = read(FD, buf, BUFSIZ);
		if (cnt <= 0) {
			/* lost carrier */
			if (cnt < 0 && errno == EIO) {
				sigblock(sigmask(SIGTERM));
				intTERM(0);
				/*NOTREACHED*/
			} else if (cnt == 0 && errno == ENOENT) {
				if (getppid() != 1)
					kill(getppid(),SIGUSR1);
				sigblock(sigmask(SIGTERM));
				intTERM(0);
				/*NOTREACHED*/
			} else if (cnt < 0) {
				if (getppid() != 1)
					kill(getppid(),SIGUSR1);
				sigblock(sigmask(SIGTERM));
				intTERM(0);
				/*NOTREACHED*/
			}
			continue;
		}
#define	ALLSIGS	sigmask(SIGEMT)|sigmask(SIGTERM)|sigmask(SIGIOT)|sigmask(SIGSYS)
		omask = sigblock(ALLSIGS);
		for (cp = buf; cp < buf + cnt; cp++)
			*cp &= 0177;
		if (write(1, buf, cnt) < 0)
			exit(1);
		if (boolean(value(SCRIPT)) && fscript != NULL) {
			if (!boolean(value(BEAUTIFY))) {
				fwrite(buf, 1, cnt, fscript);
				continue;
			}
			for (cp = buf; cp < buf + cnt; cp++)
				if ((*cp >= ' ' && *cp <= '~') ||
				    any(*cp, value(EXCEPTIONS)))
					putc(*cp, fscript);
		}
	}
}
开发者ID:kusumi,项目名称:DragonFlyBSD,代码行数:60,代码来源:tipout.c


示例4: BlockSignals

ExtFunc void BlockSignals(MySigSet *saved, ...)
{
	MySigSet set;
	va_list args;
	int sig;

	va_start(args, saved);
#ifdef HAS_SIGPROCMASK
	sigemptyset(&set);
#else
	set = 0;
#endif
	while ((sig = va_arg(args, int))) {
#ifdef HAS_SIGPROCMASK
		sigaddset(&set, sig);
#else
		sig |= sigmask(sig);
#endif
	}
#ifdef HAS_SIGPROCMASK
	sigprocmask(SIG_BLOCK, &set, saved);
#else
	*saved = sigblock(set);
#endif
	va_end(args);
}
开发者ID:naphthalene,项目名称:tnetris,代码行数:26,代码来源:util.c


示例5: sig_trap

/*
 * call-seq:
 *   Signal.trap( signal, proc ) => obj
 *   Signal.trap( signal ) {| | block } => obj
 *
 * Specifies the handling of signals. The first parameter is a signal
 * name (a string such as ``SIGALRM'', ``SIGUSR1'', and so on) or a
 * signal number. The characters ``SIG'' may be omitted from the
 * signal name. The command or block specifies code to be run when the
 * signal is raised. If the command is the string ``IGNORE'' or
 * ``SIG_IGN'', the signal will be ignored. If the command is
 * ``DEFAULT'' or ``SIG_DFL'', the operating system's default handler
 * will be invoked. If the command is ``EXIT'', the script will be
 * terminated by the signal. Otherwise, the given command or block
 * will be run.
 * The special signal name ``EXIT'' or signal number zero will be
 * invoked just prior to program termination.
 * trap returns the previous handler for the given signal.
 *
 *     Signal.trap(0, proc { puts "Terminating: #{$$}" })
 *     Signal.trap("CLD")  { puts "Child died" }
 *     fork && Process.wait
 *
 * produces:
 *     Terminating: 27461
 *     Child died
 *     Terminating: 27460
 */
static VALUE
sig_trap(int argc, VALUE *argv)
{
    struct trap_arg arg;

    rb_secure(2);
    if (argc == 0 || argc > 2) {
	rb_raise(rb_eArgError, "wrong number of arguments -- trap(sig, cmd)/trap(sig){...}");
    }

    arg.sig = argv[0];
    if (argc == 1) {
	arg.cmd = rb_block_proc();
    }
    else if (argc == 2) {
	arg.cmd = argv[1];
    }

    if (OBJ_TAINTED(arg.cmd)) {
	rb_raise(rb_eSecurityError, "Insecure: tainted signal trap");
    }
#ifndef _WIN32
    /* disable interrupt */
# ifdef HAVE_SIGPROCMASK
    sigfillset(&arg.mask);
    sigprocmask(SIG_BLOCK, &arg.mask, &arg.mask);
# else
    arg.mask = sigblock(~0);
# endif

    return rb_ensure(trap, (VALUE)&arg, trap_ensure, (VALUE)&arg);
#else
    return trap(&arg);
#endif
}
开发者ID:RWB01,项目名称:Code-Translator,代码行数:63,代码来源:signal.c


示例6: abort

abort()
{
	sigblock(~0);
	signal(SIGILL, SIG_DFL);
	sigsetmask(~sigmask(SIGILL));
	kill(getpid(), SIGILL);
}
开发者ID:phamthechung,项目名称:photonbsd,代码行数:7,代码来源:abort.c


示例7: vox_close

static void
vox_close (struct sound_device *sd)
{
  if (sd->fd >= 0)
    {
      /* On GNU/Linux, it seems that the device driver doesn't like to
	 be interrupted by a signal.  Block the ones we know to cause
	 troubles.  */
#ifdef SIGIO
      sigblock (sigmask (SIGIO));
#endif
      turn_on_atimers (0);

      /* Flush sound data, and reset the device.  */
      ioctl (sd->fd, SNDCTL_DSP_SYNC, NULL);

      turn_on_atimers (1);
#ifdef SIGIO
      sigunblock (sigmask (SIGIO));
#endif

      /* Close the device.  */
      emacs_close (sd->fd);
      sd->fd = -1;
    }
}
开发者ID:mmaruska,项目名称:emacs,代码行数:26,代码来源:sound.c


示例8: cpu_mask_all_signals

void
cpu_mask_all_signals(void)
{
	sigblock(sigmask(SIGALRM)|sigmask(SIGIO)|sigmask(SIGQUIT)|
		 sigmask(SIGUSR1)|sigmask(SIGTERM)|sigmask(SIGWINCH)|
		 sigmask(SIGUSR2));
}
开发者ID:mihaicarabas,项目名称:dragonfly,代码行数:7,代码来源:machintr.c


示例9: SetClockRate

/*
 * The argument is the new rate in old_tick units.
 */
int
SetClockRate(
	long rate
	)
{
	long mask;

	if (lseek(kmem, (off_t)nl[0].n_value, 0) == -1L)
	    return (-1);

	mask = sigblock(sigmask(SIGALRM));

	if (write(kmem, (caddr_t)&rate, sizeof(rate)) != sizeof(rate)) {
		sigsetmask(mask);
		return (-1);
	}

	sigsetmask(mask);

	if (rate != default_rate) {
		if (verbose > 3) {
			printf("adjtimed: clock rate (%lu) %ldus/s\n", rate,
			       (rate - default_rate) * tick_rate);
		}
		if (sysdebug > 3) {
			msyslog(LOG_INFO, "clock rate (%lu) %ldus/s", rate,
				(rate - default_rate) * tick_rate);
		}
	}

	return (0);
} /* SetClockRate */
开发者ID:VargMon,项目名称:netbsd-cvs-mirror,代码行数:35,代码来源:adjtimed.c


示例10: writeroob

/* ARGSUSED */
static void
writeroob(int signum)
{
	int mask;

	if (!dosigwinch) {
		/*
		 * Start tracking window size.  It doesn't matter which
		 * order the next two are in, because we'll be unconditionally
		 * sending a size notification in a moment.
		 */
		(void) sigset(SIGWINCH, sigwinch);
		dosigwinch = B_TRUE;

		/*
		 * It would be bad if a SIGWINCH came in between the ioctl
		 * and sending the data.  It could result in the SIGWINCH
		 * handler sending a good message, and then us sending an
		 * outdated or inconsistent message.
		 *
		 * Instead, if the change is made before the
		 * ioctl, the sigwinch handler will send a size message
		 * and we'll send another, identical, one.  If the change
		 * is made after the ioctl, we'll send a message with the
		 * old value, and then the sigwinch handler will send
		 * a revised, correct one.
		 */
		mask = sigblock(sigmask(SIGWINCH));
		if (ioctl(STDIN_FILENO, TIOCGWINSZ, &winsize) == 0)
			sendwindow();
		sigsetmask(mask);
	}
}
开发者ID:alhazred,项目名称:onarm,代码行数:34,代码来源:rlogin.c


示例11: release_sigint

/* Cause SIGINT to not be delivered until the corresponding call to
   release_sigint(). */
static void
block_sigint ()
{
  if (sigint_blocked)
    return;

#if defined (__EMX__)
  sigemptyset (&sigint_set);
  sigemptyset (&sigint_oset);
  sigaddset (&sigint_set, SIGINT);
  sigaddset (&sigint_set, SIGBREAK);
  sigprocmask (SIG_BLOCK, &sigint_set, &sigint_oset);
#else
#if defined (HAVE_POSIX_SIGNALS)
  sigemptyset (&sigint_set);
  sigemptyset (&sigint_oset);
  sigaddset (&sigint_set, SIGINT);
  sigprocmask (SIG_BLOCK, &sigint_set, &sigint_oset);
#else /* !HAVE_POSIX_SIGNALS */
#  if defined (HAVE_BSD_SIGNALS)
  sigint_oldmask = sigblock (sigmask (SIGINT));
#  else /* !HAVE_BSD_SIGNALS */
#    if defined (HAVE_USG_SIGHOLD)
  sighold (SIGINT);
#    endif /* HAVE_USG_SIGHOLD */
#  endif /* !HAVE_BSD_SIGNALS */
#endif /* !HAVE_POSIX_SIGNALS */
#endif

  sigint_blocked = 1;
}
开发者ID:OS2World,项目名称:APP-MATH-Octave,代码行数:33,代码来源:rltty.c


示例12: suspend

 void
 suspend (int n)
 {
+	sigset_t set;
+
 	restoreterm();
 	signal(SIGTSTP, SIG_DFL);
-	sigsetmask(sigblock(0) &~ mask(SIGTSTP));
+	sigaddset(&set, SIGTSTP);
+	sigprocmask(SIG_UNBLOCK, &set, NULL);
 	kill(0, SIGTSTP);
-	sigblock(mask(SIGTSTP));
+	sigprocmask(SIG_BLOCK, &set, NULL);
 	signal(SIGTSTP, suspend);
 	icbterm();
 	continued = 1;
开发者ID:BlueFireworks,项目名称:pkgsrc,代码行数:16,代码来源:patch-src_signals.c


示例13: __ostimer_blockall

void __ostimer_blockall(void)
{
#ifndef NO_POSIX_SIGS
   (void) sigprocmask( SIG_BLOCK, &timer_block_mask, SIGSET_NULL ) ;
#else
   (void) sigblock( timer_block_mask ) ;
#endif
}
开发者ID:SethRobertson,项目名称:libclc,代码行数:8,代码来源:sysdep.c


示例14: checkup

/*
 * Check that we are not burning resources
 */
static void
checkup(void)
{

  static int max_fd = 0;
  static char *max_mem = 0;

  int next_fd = dup(0);
  caddr_t next_mem = sbrk(0);
  close(next_fd);

  if (max_fd < next_fd) {
    dlog("%d new fds allocated; total is %d",
	 next_fd - max_fd, next_fd);
    max_fd = next_fd;
  }
  if (max_mem < next_mem) {
#ifdef HAVE_GETPAGESIZE
    dlog("%#lx bytes of memory allocated; total is %#lx (%ld pages)",
	 (long) (next_mem - max_mem), (unsigned long) next_mem,
	 ((long) next_mem + getpagesize() - 1) / (long) getpagesize());
#else /* not HAVE_GETPAGESIZE */
    dlog("%#lx bytes of memory allocated; total is %#lx",
	 (long) (next_mem - max_mem), (unsigned long) next_mem);
#endif /* not HAVE_GETPAGESIZE */
    max_mem = next_mem;

  }
}
#else  /* not DEBUG */
#define checkup()
#endif /* not DEBUG */


static int
#ifdef HAVE_SIGACTION
do_select(sigset_t smask, int fds, fd_set *fdp, struct timeval *tvp)
#else /* not HAVE_SIGACTION */
do_select(int smask, int fds, fd_set *fdp, struct timeval *tvp)
#endif /* not HAVE_SIGACTION */
{

  int sig;
  int nsel;

  if ((sig = setjmp(select_intr))) {
    select_intr_valid = 0;
    /* Got a signal */
    switch (sig) {
    case SIGINT:
    case SIGTERM:
      amd_state = Finishing;
      reschedule_timeout_mp();
      break;
    }
    nsel = -1;
    errno = EINTR;
  } else {
    select_intr_valid = 1;
    /*
     * Invalidate the current clock value
     */
    clock_valid = 0;
    /*
     * Allow interrupts.  If a signal
     * occurs, then it will cause a longjmp
     * up above.
     */
#ifdef HAVE_SIGACTION
    sigprocmask(SIG_SETMASK, &smask, NULL);
#else /* not HAVE_SIGACTION */
    (void) sigsetmask(smask);
#endif /* not HAVE_SIGACTION */

    /*
     * Wait for input
     */
    nsel = select(fds, fdp, (fd_set *) 0, (fd_set *) 0,
		  tvp->tv_sec ? tvp : (struct timeval *) 0);
  }

#ifdef HAVE_SIGACTION
  sigprocmask(SIG_BLOCK, &masked_sigs, NULL);
#else /* not HAVE_SIGACTION */
  (void) sigblock(MASKED_SIGS);
#endif /* not HAVE_SIGACTION */

  /*
   * Perhaps reload the cache?
   */
  if (do_mapc_reload < clocktime()) {
    mapc_reload();
    do_mapc_reload = clocktime() + gopt.map_reload_interval;
  }
  return nsel;
}
开发者ID:AzerTyQsdF,项目名称:osx,代码行数:99,代码来源:nfs_start.c


示例15: block_io_and_alarm

void
block_io_and_alarm(void)
{
	int mask;

	mask = sigmask(SIGIO) | sigmask(SIGALRM);
	if (sigblock(mask))
	    msyslog(LOG_ERR, "block_io_and_alarm: sigblock() failed: %m");
}
开发者ID:2asoft,项目名称:freebsd,代码行数:9,代码来源:iosignal.c


示例16: main

int main(int argc, char *argv[])
{
	sigblock(sigmask(SIGPIPE)); /* something to make the mask interesting */
	signal(SIGTSTP, my_handler);
	asm {brk 0}
	setjmp(my_jump);
	asm {brk 1}
	for (;;);
}
开发者ID:GnoConsortium,项目名称:gno,代码行数:9,代码来源:setjmptest.c


示例17: setsignal

/* trap a signal, unless it is being ignored. */
static void
setsignal(int sig)
{
	int omask = sigblock(sigmask(sig));

	if (signal(sig, exit) == SIG_IGN)
		(void)signal(sig, SIG_IGN);
	(void)sigsetmask(omask);
}
开发者ID:JabirTech,项目名称:Source,代码行数:10,代码来源:rlogin.c


示例18: vfork_and_run

pid_t vfork_and_run(void (*fn)(void*) /*NORETURN*/, void *arg) {
	/* GNO's fork2 call will return immediately and allow the parent and 
	 * child processes to execute concurrently using the same memory
	 * space.  To prevent them stomping on each other, we want to get
	 * behavior like a traditional vfork() implementation, where the
	 * parent blocks until the child terminates or execs.
	 *
	 * Our approach is to check the process tables to make sure the
	 * child has actually finished or exec'd.  If not, we loop and try again.
	 * We can't just rely on the fact that the child signaled us, because
	 * it may still be running in libc's implementation of exec*.
	 */
	
	long oldmask;
	pid_t pid;
	kvmt *kvm_context;
	struct pentry *proc_entry;
	int done = 0;
	
	/* Isolate child process's environment from parent */
	if (environPush() != 0)
		return  -1;
	
	/* Block all signals for now */
	oldmask = sigblock(-1);
	
	pid = fork2(fork_thunk, CHILD_STACKSIZE, 0, forked_child_name, 
				(sizeof(fn) + sizeof(arg) + sizeof(oldmask) + 1) / 2, 
				fn, arg, oldmask);
	if (pid < 0) 
		goto ret;
	
	while (!done) {
		/* Wait for ~100 ms.  If procsend worked, the child could send a 
		 * message with it to end the waiting earlier, but this isn't 
		 * possible in GNO 2.0.6 because procsend is broken.  This isn't
		 * too big an issue, since 100ms isn't very long to wait anyhow. */
		procrecvtim(1);
		
		/* Check if the child is really dead or forked by inspecting
		 * the kernel's process entry for it. */
		kvm_context = kvm_open();
		if (kvm_context == NULL)
			break;
		proc_entry = kvmgetproc(kvm_context, pid);
		if (proc_entry == NULL 
			|| (proc_entry->args != NULL 
				&& strcmp(forked_child_name, proc_entry->args + 8) != 0))
			done = 1;
		kvm_close(kvm_context);
	}
	
ret:
	sigsetmask(oldmask);
	environPop();
	return pid;
}
开发者ID:sheumann,项目名称:telnetd,代码行数:57,代码来源:vfork.and.run.c


示例19: tstp

/*
 * handle stop and start signals
 *
 * @(#)tstp.c	5.6 (Berkeley) 3/3/91
 */
void
tstp() {

# ifdef SIGTSTP

	SGTTY	tty;
#ifdef POSIX
	sigset_t mask, omask;
#else
	int	omask;
#endif
# ifdef DEBUG
	if (outf)
		fflush(outf);
# endif
	tty = _tty;
	mvcur(0, COLS - 1, LINES - 1, 0);
	endwin();
	fflush(stdout);
	/* reset signal handler so kill below stops us */
	signal(SIGTSTP, SIG_DFL);
#ifdef POSIX
	sigemptyset(&mask);	
	sigaddset(&mask, SIGTSTP);
	sigprocmask(SIG_SETMASK, &mask, &omask);
	kill(0, SIGTSTP);
	sigprocmask(SIG_SETMASK, &omask, 0);
#else
#define	mask(s)	(1 << ((s)-1))
	omask = sigsetmask(sigblock(0) &~ mask(SIGTSTP));
	kill(0, SIGTSTP);
	sigblock(mask(SIGTSTP));
#endif
	signal(SIGTSTP, tstp);
	_tty = tty;
#ifdef POSIX
	tcsetattr(_tty_ch, TCSADRAIN, &_tty);
#else
	ioctl(_tty_ch, TIOCSETP, &_tty);
#endif
	wrefresh(curscr);
# endif	SIGTSTP
}
开发者ID:LambdaCalculus379,项目名称:SLS-1.02,代码行数:48,代码来源:tstp.c


示例20: sighold

/* Hold a signal =========================================================== */
int sighold(int signal_Number)
{
	/* Block a specific signal */
	if (sigblock(sigmask(signal_Number)) == -1)
	{
		return -1;
	}

	return 0;
}
开发者ID:Vladimir84,项目名称:rcc,代码行数:11,代码来源:psignal.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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