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

C++ sigrelse函数代码示例

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

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



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

示例1: abort

/*
 * abort() - terminate current process with dump via SIGABRT
 */
void
abort(void)
{
	sigset_t	set;
	struct sigaction	act;

	if (!sigaction(SIGABRT, NULL, &act) &&
	    act.sa_handler != SIG_DFL && act.sa_handler != SIG_IGN) {
		/*
		 * User handler is installed, invokes user handler before
		 * taking default action.
		 *
		 * Send SIGABRT, unblock SIGABRT if blocked.
		 * If there is pending signal SIGABRT, we only need to unblock
		 * SIGABRT.
		 */
		if (!sigprocmask(SIG_SETMASK, NULL, &set) &&
		    sigismember(&set, SIGABRT)) {
			if (!sigpending(&set) && !sigismember(&set, SIGABRT))
				(void) raise(SIGABRT);
			(void) sigrelse(SIGABRT);
		} else
			(void) raise(SIGABRT);
	}

	if (++pass == 1)
		__cleanup();

	for (;;) {
		(void) signal(SIGABRT, SIG_DFL);
		(void) sigrelse(SIGABRT);
		(void) raise(SIGABRT);
	}
}
开发者ID:NanXiao,项目名称:illumos-joyent,代码行数:37,代码来源:abort.c


示例2: semaphore_wait

/**
 * Decrements the value of the given semaphore.
 * If the value goes below 0, the thread is put into a WAIT state.
 */
void semaphore_wait(int semaphore) {

	// disable alarm while working with semaphore
	sighold(SIGALRM);

#if DEBUG == 1
	char print[100];
	sprintf(print, "wait called on semaphore %d with value %d\n", semaphore,
			semaphores[semaphore]->value);
	perror(print);
#endif

	semaphores[semaphore]->value -= 1;
	if (semaphores[semaphore]->value < 0) {

#if DEBUG == 1
		sprintf(print, "thread %d put on waitqueue\n", current_thread);
		perror(print);
#endif

		// block thread
		threads[current_thread]->state = WAIT;
		// put it on the wait queue
		list_append_int(semaphores[semaphore]->thread_queue, current_thread);

		//unblock alarm and wait for scheduler to take over
		sigrelse(SIGALRM);
		while (threads[current_thread]->state == WAIT)
			; // when semaphore is signaled thread will be RUNNABLE again and return from this function
	} else {
		//don't block thread, unblock alarm and go back to the thread
		sigrelse(SIGALRM);
	}
}
开发者ID:ssalenik,项目名称:nothomework,代码行数:38,代码来源:sillythreads.c


示例3: do_test

static int
do_test (void)
{
  int result = 0;
  int e;

#define RUN(test) \
  errno = 0;								      \
  e = test;								      \
  if (e != -1)								      \
    {									      \
      printf ("%s returned %d\n", #test, e);				      \
      result = 1;							      \
    }									      \
  else if (errno != EINVAL)						      \
    {									      \
      printf ("%s didn't set errno to EINVAL (%s instead)\n",		      \
	      #test, strerror (errno));					      \
      result = 1;							      \
    }

  RUN (sighold (-1));
  RUN (sighold (_NSIG + 100));

  RUN (sigrelse (-1));
  RUN (sigrelse (_NSIG + 100));

  return result;
}
开发者ID:AubrCool,项目名称:glibc,代码行数:29,代码来源:tst-sigsimple.c


示例4: twine_mutex_lock

void twine_mutex_lock(twine_mutex *lockVar) {
    sighold(SIGALRM);           // stop signals for atomic operation
    while (lockVar->value) {    // wait while lock is 1 (locked)
        sigrelse(SIGALRM);
        sighold(SIGALRM);
    }
    lockVar->value = 1;         // 1 = locked
    sigrelse(SIGALRM);
}
开发者ID:breily,项目名称:twine,代码行数:9,代码来源:thread.c


示例5: sighold

void semaphore::wait(void){
	sighold(SIGALRM);
	this->value -= 1;
	if(this->value < 0){
		getRunningThread()->state = BLOCKED;
		this->waitQueue.push(getRunningThread());
		sigrelse(SIGALRM);
		raise(SIGALRM);
	}
	else{
		sigrelse(SIGALRM);
	}
}
开发者ID:chenbk85,项目名称:eThread,代码行数:13,代码来源:semaphore.cpp


示例6: sem_wait

/*
 * Tries to gain access to a critical section.
 * Will either continue, or be put in the semaphore's private queue
 */
void sem_wait(sem_t *s){
	sighold(14);
	if(s->count > 0){
		s->count--;
		sigrelse(14);
		return;
	}
	/* Count is 0 */
	sem_enq(s, running);
	deq();
	if(s->last)
		swapcontext(s->last->thread_context, running->thread_context);
	sigrelse(14);
}
开发者ID:wtaylor45,项目名称:Thread-Library,代码行数:18,代码来源:t_lib.c


示例7: cupsdReleaseSignals

void
cupsdReleaseSignals(void)
{
  holdcount --;
  if (holdcount > 0)
    return;

#ifdef HAVE_SIGSET
  sigrelse(SIGTERM);
  sigrelse(SIGCHLD);
#elif defined(HAVE_SIGACTION)
  sigprocmask(SIG_SETMASK, &holdmask, NULL);
#endif /* HAVE_SIGSET */
}
开发者ID:ChErePOdaViLka,项目名称:cups,代码行数:14,代码来源:main.c


示例8: relsesigs

/*
 * Release signals SIGHUP - SIGQUIT
 */
void
relsesigs(void)
{
#ifndef OLD_BSD_SIGS
	if (--sigdepth == 0)
#ifdef VMUNIX
		sigsetmask(omask);
#else
		sigprocmask(SIG_SETMASK, &omask, NULL);
#endif
#else
	sigrelse(SIGHUP);
	sigrelse(SIGINT);
	sigrelse(SIGQUIT);
#endif
}
开发者ID:FilipinOTech,项目名称:illumos-gate,代码行数:19,代码来源:fio.c


示例9: semaphore_signal

/**
 * Increments the value of the given semaphore.
 * If the value was  0, then the thread at the top of the wait queue is put on the runqueue.
 */
void semaphore_signal(int semaphore) {
	int next_thread;
	// disable alarm while working with semaphore
	sighold(SIGALRM);

#if DEBUG == 1
	char print[100];
	sprintf(print, "signaling semaphore %d with value %d\n", semaphore,
			semaphores[semaphore]->value);
	perror(print);
#endif

	if (semaphores[semaphore]->value < 0) {

		// make first thread on the wait queue RUNNABLE
		next_thread = list_shift_int(semaphores[semaphore]->thread_queue);
		if (next_thread == 0) {
			perror("no threads on waitqueue\n");
			exit(-1);
		}

#if DEBUG == 1
		sprintf(print, "signaling thread %d\n", next_thread);
		perror(print);
#endif

		threads[next_thread]->state = RUNNABLE;
		list_append_int(runqueue, next_thread);
	}
	semaphores[semaphore]->value += 1;
	sigrelse(SIGALRM);
}
开发者ID:ssalenik,项目名称:nothomework,代码行数:36,代码来源:sillythreads.c


示例10: umem_do_abort

/*
 * We can't use abort(3C), since it closes all of the standard library
 * FILEs, which can call free().
 *
 * In addition, we can't just raise(SIGABRT), since the current handler
 * might do allocation.  We give them once chance, though.
 */
static void __NORETURN
umem_do_abort(void)
{
#ifdef _WIN32
	abort();
#else
	if (firstexit(UMEM_EXIT_ABORT)) {
		(void) raise(SIGABRT);
	}

	for (;;) {
#if defined(__FreeBSD__)
		sigset_t set;
		struct sigaction sa;

		sa.sa_handler = SIG_DFL;
		(void) sigaction(SIGABRT, &sa, NULL);
		(void) sigemptyset (&set);
		(void) sigaddset (&set, SIGABRT);
		(void) sigprocmask (SIG_UNBLOCK, &set, NULL);
		(void) raise (SIGABRT);
#else
		(void) signal(SIGABRT, SIG_DFL);
#if !defined(ANDROID) && !defined(ROUTER) && !defined(ARM)
		(void) sigrelse(SIGABRT);
#endif
		(void) raise(SIGABRT);
#endif
	}
#endif
}
开发者ID:Antares84,项目名称:asuswrt-merlin,代码行数:38,代码来源:umem_fail.c


示例11: pause_on_sigusr

void
pause_on_sigusr( int which )
{
  #ifndef HAVE_DOSISH_SYSTEM
   #ifdef HAVE_SIGPROCMASK
    sigset_t mask, oldmask;

    assert( which == 1 );
    sigemptyset( &mask );
    sigaddset( &mask, SIGUSR1 );

    sigprocmask( SIG_BLOCK, &mask, &oldmask );
    while( !caught_sigusr1 )
	sigsuspend( &oldmask );
    caught_sigusr1 = 0;
    sigprocmask( SIG_UNBLOCK, &mask, NULL );
   #else 
     assert (which == 1);
     sighold (SIGUSR1);
     while (!caught_sigusr1)
         sigpause(SIGUSR1);
     caught_sigusr1 = 0;
     sigrelse(SIGUSR1); ????
   #endif /*!HAVE_SIGPROCMASK*/
  #endif
}
开发者ID:BridgeNY,项目名称:purdue,代码行数:26,代码来源:signal.c


示例12: TEST

TEST(signal, sighold_sigpause_sigrelse) {
  static int sigalrm_handler_call_count;
  auto sigalrm_handler = [](int) { sigalrm_handler_call_count++; };
  ScopedSignalHandler sigalrm{SIGALRM, sigalrm_handler};
  ScopedSignalMask mask;
  sigset_t set;

  // sighold(SIGALRM) should add SIGALRM to the signal mask ...
  ASSERT_EQ(0, sighold(SIGALRM));
  ASSERT_EQ(0, sigprocmask(SIG_SETMASK, 0, &set));
  EXPECT_TRUE(sigismember(&set, SIGALRM));

  // ... preventing our SIGALRM handler from running ...
  raise(SIGALRM);
  ASSERT_EQ(0, sigalrm_handler_call_count);
  // ... until sigpause(SIGALRM) temporarily unblocks it.
  ASSERT_EQ(-1, sigpause(SIGALRM));
  ASSERT_EQ(EINTR, errno);
  ASSERT_EQ(1, sigalrm_handler_call_count);

  // But sigpause(SIGALRM) shouldn't permanently unblock SIGALRM.
  ASSERT_EQ(0, sigprocmask(SIG_SETMASK, 0, &set));
  EXPECT_TRUE(sigismember(&set, SIGALRM));

  ASSERT_EQ(0, sigrelse(SIGALRM));
  ASSERT_EQ(0, sigprocmask(SIG_SETMASK, 0, &set));
  EXPECT_FALSE(sigismember(&set, SIGALRM));
}
开发者ID:316181444,项目名称:platform_bionic,代码行数:28,代码来源:signal_test.cpp


示例13: BIO_dump_cmd

/*
 * Name:		BIO_dump_cmd
 * Description:	Dump the output of invoking a command
 *		to a BIO.
 *
 * Arguments:	cmd - Command to invoke
 *		bio - BIO to dump output of command to
 *		only 'stdout' is dumped.
 * Returns :   	0 - success
 *		nonzero - failure.  errors printed to screen.
 */
int
BIO_dump_cmd(char *cmd, BIO *bio)
{
	char	buf[BLK_SIZE];
	FILE	*fp;
	int	rc;

	/* start up the process */
	if ((fp = epopen(cmd, "r")) == NULL) {
		rpterr();
		return (1);
	}

	/* read output in chunks, transfer to BIO */
	while (fread(buf, BLK_SIZE, 1, fp) == 1) {
		if (BIO_write(bio, buf, BLK_SIZE) != BLK_SIZE) {
			(void) sighold(SIGINT);
			(void) sighold(SIGHUP);
			(void) epclose(fp);
			(void) sigrelse(SIGINT);
			(void) sigrelse(SIGHUP);
			rpterr();
			return (1);
		}
	}

	/* done with stream, make sure no errors were encountered */
	if (ferror(fp)) {
		(void) epclose(fp);
		rpterr();
		return (1);
	}

	/* done, close stream, report any errors */
	(void) sighold(SIGINT);
	(void) sighold(SIGHUP);
	rc = epclose(fp);
	(void) sigrelse(SIGINT);
	(void) sigrelse(SIGHUP);
	if (rc != 0) {
		rpterr();
		return (1);
	}

	return (rc);
}
开发者ID:apprisi,项目名称:illumos-gate,代码行数:57,代码来源:pkgtrans.c


示例14: emulator_run

void emulator_run(struct emulator *emu)
{
    cur_run_emu = emu;
    sigset(SIGINT, sig_int_handler);
    while (!emu->stop_prog)
        emulator_run_next_inst(emu);
    sigrelse(SIGINT);
}
开发者ID:DSMan195276,项目名称:cmips,代码行数:8,代码来源:mips.c


示例15: sem_signal

/*
 * Tells the other semaphores that the running thread is done with the critical section
 * Removes the first waiting thread in the semaphore queue
 */
void sem_signal(sem_t *s){
	sighold(14);
	if(s->first == NULL || s->count > 0){
		s->count++;
	}else if(s->count <= 0){ /* There is a waiting thread, counter is 0 */
		sem_deq(s);/* Add thread to ready queue */
	}
	sigrelse(14);
}
开发者ID:wtaylor45,项目名称:Thread-Library,代码行数:13,代码来源:t_lib.c


示例16: main

int main(void)
{
	if (sigrelse(SIGABRT) != 0) {
		perror("Sigrelse failed");
		return PTS_UNRESOLVED;
	}
	printf("Test PASSED\n");
	return PTS_PASS;
}
开发者ID:1587,项目名称:ltp,代码行数:9,代码来源:2-1.c


示例17: main

int main()
{

	if ((int)sigrelse(SIGABRT) != 0) {
		perror("sigrelse failed -- returned -- test aborted");
		return PTS_UNRESOLVED;
	} 
	printf("sigrelse passed\n");
	return PTS_PASS;
}
开发者ID:chathhorn,项目名称:posixtestsuite,代码行数:10,代码来源:2-1.c


示例18: ReleaseSignal

void
ReleaseSignal(int sig) {
#ifdef HAVE_SIGRELSE
  sigrelse(sig);
#else
  sigset_t set, oset;
  sigemptyset(&set);
  sigaddset(&set, sig);
  sigprocmask(SIG_UNBLOCK, &set, &oset);
#endif
}
开发者ID:LogisticalComputingAndInternetworking,项目名称:LoRS,代码行数:11,代码来源:osutil.c


示例19: release_signals

void
release_signals(void *parm)

{
#ifdef HAVE_SIGACTION
    sigprocmask(SIG_UNBLOCK, (sigset_t *)parm, NULL);
#endif

#ifdef HAVE_SIGHOLD
    sigrelse(SIGINT);
    sigrelse(SIGQUIT);
    sigrelse(SIGTSTP);
#ifdef SIGWINCH
    sigrelse(SIGWINCH);
#endif
#endif

#ifdef BSD_SIGNALS
    (void) sigsetmask((int)parm);
#endif
}
开发者ID:alexandermerritt,项目名称:dragonfly,代码行数:21,代码来源:top.c


示例20: cleanup

/*
 * void
 * cleanup() - performs all ONE TIME cleanup for this test at
 *             completion or premature exit.
 *  Release the signal 'SIGUSR1'  if still in pending state.
 */
void cleanup()
{
	/*
	 * print timing stats if that option was specified.
	 * print errno log if that option was specified.
	 */
	TEST_CLEANUP;

	/* Release the signal 'SIGUSR1' if in pending state */
	if (sigrelse(SIGUSR1) == -1) {
		tst_brkm(TBROK, NULL, "Failed to release 'SIGUSR1' in cleanup");
	}

}
开发者ID:Nan619,项目名称:ltp-ddt,代码行数:20,代码来源:vfork02.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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