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


C++ sigblock函数代码示例

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


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


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