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

C++ sigsetmask函数代码示例

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

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



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

示例1: 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


示例2: RestoreSignals

ExtFunc void RestoreSignals(MySigSet *saved, MySigSet *set)
{
#ifdef HAS_SIGPROCMASK
	sigprocmask(SIG_SETMASK, set, saved);
#else
	if (saved)
		*saved = sigsetmask(*set);
	else
		sigsetmask(*set);
#endif
}
开发者ID:naphthalene,项目名称:tnetris,代码行数:11,代码来源:util.c


示例3: sig_unblock

void sig_unblock(int sig)
{
#ifdef HASSIGPROCMASK
    sigset_t ss;
    sigemptyset(&ss);
    sigaddset(&ss,sig);
    sigprocmask(SIG_UNBLOCK,&ss,(sigset_t *) 0);
#else
    sigsetmask(sigsetmask(~0) & ~(1 << (sig - 1)));
#endif
}
开发者ID:NikolaMandic,项目名称:containers,代码行数:11,代码来源:sig_block.c


示例4: cleanup

void
cleanup(int sig)
{
#ifdef _CRAY
    static int incleanup = 0;
    int t;
    int child_status; /* status of child process as returned by waitpid */
    int flags = WNOHANG|WUNTRACED;

    /*
     * 1: Pick up the zombie, if we are being called
     *    as the signal handler.
     * 2: If we are a nested cleanup(), return.
     * 3: Try to clean up TMPDIR.
     * 4: Fill in utmp with shutdown of process.
     * 5: Close down the network and pty connections.
     * 6: Finish up the TMPDIR cleanup, if needed.
     */
    if (sig == SIGCHLD) {
	while (waitpid(-1, &child_status, flags) > 0)
	    ;	/* VOID */
	/* Check if the child process was stopped
	 * rather than exited.  We want cleanup only if
	 * the child has died.
	 */
	if (WIFSTOPPED(child_status)) {
	    return;
	}
    }
    t = sigblock(sigmask(SIGCHLD));
    if (incleanup) {
	sigsetmask(t);
	return;
    }
    incleanup = 1;
    sigsetmask(t);

    t = cleantmp(&wtmp);
    setutent();	/* just to make sure */
#endif /* CRAY */
    rmut(line);
    close(ourpty);
    shutdown(net, 2);
#ifdef _CRAY
    if (t == 0)
	cleantmp(&wtmp);
#endif /* CRAY */
    exit(1);
}
开发者ID:2asoft,项目名称:freebsd,代码行数:49,代码来源:sys_term.c


示例5: 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


示例6: restart_doit

RETSIGTYPE
restart_doit(int a)
{
    char * name = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, 
                                        NETSNMP_DS_LIB_APPTYPE);
    snmp_shutdown(name);

    /*  This signal handler may run with SIGALARM blocked.
     *  Since the signal mask is preserved accross execv(), we must 
     *  make sure that SIGALARM is unblocked prior of execv'ing.
     *  Otherwise SIGALARM will be ignored in the next incarnation
     *  of snmpd, because the signal is blocked. And thus, the 
     *  restart doesn't work anymore. 
     */ 
#if HAVE_SIGBLOCK 
    sigsetmask(0);
#endif 

    /*
     * do the exec 
     */
#if HAVE_EXECV
    execv(argvrestartname, argvrestartp);
    setPerrorstatus(argvrestartname);
#endif
}
开发者ID:OPSF,项目名称:uClinux,代码行数:26,代码来源:util_funcs.c


示例7: 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


示例8: async_stop_sig

static void
async_stop_sig (gdb_client_data arg)
{
  char *prompt = get_prompt ();

#if STOP_SIGNAL == SIGTSTP
  signal (SIGTSTP, SIG_DFL);
#if HAVE_SIGPROCMASK
  {
    sigset_t zero;

    sigemptyset (&zero);
    sigprocmask (SIG_SETMASK, &zero, 0);
  }
#elif HAVE_SIGSETMASK
  sigsetmask (0);
#endif
  raise (SIGTSTP);
  signal (SIGTSTP, handle_stop_sig);
#else
  signal (STOP_SIGNAL, handle_stop_sig);
#endif
  printf_unfiltered ("%s", prompt);
  gdb_flush (gdb_stdout);

  /* Forget about any previous command -- null line now will do
     nothing.  */
  dont_repeat ();
}
开发者ID:Xilinx,项目名称:gdb,代码行数:29,代码来源:event-top.c


示例9: abort

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


示例10: f77_abort

f77_abort( err_val, act_core )
{
	char first_char, *env_var;
	int core_dump;

	env_var = getenv("f77_dump_flag");
	first_char = (env_var == NULL) ? 0 : *env_var;

	signal(SIGILL, SIG_DFL);
	sigsetmask(0);			/* don't block */

	/* see if we want a core dump:
		first line checks for signals like hangup - don't dump then.
		second line checks if -lg specified to ld (e.g. by saying
			-g to f77) and checks the f77_dump_flag var. */
	core_dump = ((nargs() != 2) || act_core) &&
	    ( (_lg_flag && (first_char != 'n')) || first_char == 'y');

	if( !core_dump )
		fprintf(units[STDERR].ufd,"*** Execution terminated\n");

	f_exit();
	_cleanup();
	if( nargs() ) errno = err_val;
	else errno = -2;   /* prior value will be meaningless,
				so set it to undefined value */

	if( core_dump ) abort();
	else  exit( errno );
}
开发者ID:dank101,项目名称:4.4BSD-Alpha,代码行数:30,代码来源:f77_abort.c


示例11: plog

void
plog(int lvl, 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);
  sigprocmask(SIG_BLOCK, &chld, &old);
#else /* not HAVE_SIGACTION */
  mask = sigblock(sigmask(SIGCHLD));
#endif /* not HAVE_SIGACTION */

  if (!logfp)
    logfp = stderr;		/* initialize before possible first use */

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

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


示例12: sigprocmask

int
sigprocmask (int mode, sigset_t * mask, sigset_t * omask)
{
	sigset_t current = sigsetmask(0);

	if (omask) *omask = current;

	if (mode==SIG_BLOCK)
		current |= *mask;
	else if (mode==SIG_UNBLOCK)
		current &= ~*mask;
	else if (mode==SIG_SETMASK)
	current = *mask;

	sigsetmask(current);
	return 0;
}
开发者ID:BackupTheBerlios,项目名称:wl530g-svn,代码行数:17,代码来源:sigact.c


示例13: machdep_sys_sigprocmask

/* ==========================================================================
 * machdep_sys_sigprocmask()
 * This isn't a real implementation; we can make the assumption that the
 * pthreads library is not using oset, and that it is always blocking or
 * unblocking all signals at once.
 */
int machdep_sys_sigprocmask(int how, const sigset_t *set, sigset_t *oset)
{
    switch(how) {
      case SIG_BLOCK:
	sigblock(*set);
	break;
      case SIG_UNBLOCK:
	sigsetmask(~*set);
	break;
      case SIG_SETMASK:
	sigsetmask(*set);
	break;
      default:
	return -EINVAL;
    }
    return(OK);
}
开发者ID:NickeyWoo,项目名称:mysql-3.23.49,代码行数:23,代码来源:engine-r2000-ultrix-4.2.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: forkX

/*
static int forkX(){
*/
static int forkX(PCStr(what)) {
    int nmask,smask;
    int pmask,tmask;
    int pid;
    vfuncp opsig = 0;
    vfuncp otsig = 0;

    forker_pid = getpid();
    nmask = sigmask(SIGPIPE)|sigmask(SIGTERM)|sigmask(SIGINT);
    nmask |= sigmask(SIGHUP);
    pmask = proc_sigblock(nmask); /* sigblock can be for a thread only */
    tmask = sigblock(nmask);
    /*
    smask = sigblock(nmask);
    */
    opsig = signal(SIGPIPE,sigPIPEi);
    pid = fork();
    signal(SIGPIPE,opsig);
    /*
    sigsetmask(smask);
    */

    if( pid ) {
        sigsetmask(tmask);
        proc_sigsetmask(pmask);
    } else {
        /*
         * 9.9.4 MTSS clear inherited env. first not to let signals
         * be processed under the thread env. of the parent that is
         * not to be inherited.
        */
        MyPID = my_pid = getpid();
        on_fork(MyPID);
        execCloseOnFork(what);
        /*
         * try to capture pending SIGTERM and exit
         */
        otsig = signal(SIGTERM,sigTERMx);
        sigsetmask(tmask);
        proc_sigsetmask(pmask);
        usleep(1);
        signal(SIGTERM,otsig);
    }
    return pid;
}
开发者ID:Nervous-,项目名称:Psiphon3-for-Linux,代码行数:48,代码来源:forkspawn.c


示例16: 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


示例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: restore_sigs

static void
restore_sigs (masktype *oldmask)
{
#ifdef POSIX_SIGNALS
    sigprocmask(SIG_SETMASK, oldmask, (sigset_t*)0);
#else
    sigsetmask(*oldmask);
#endif /* POSIX_SIGNALS */
}
开发者ID:FarazShaikh,项目名称:LikewiseSMB2,代码行数:9,代码来源:kcmd.c


示例19: 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


示例20: Sig2HandlerFunction

void Sig2HandlerFunction(int)
{
    restore_modex = TRUE;

    sigaction(SIGUSR1, &sig1handler, NULL);
    sigaction(SIGUSR2, &oldsig2handler, NULL);
    sigsetmask (0);
    raise(SIGUSR2);
}
开发者ID:twinaphex,项目名称:snes9x-150,代码行数:9,代码来源:svga.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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