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

C++ sigqueue函数代码示例

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

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



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

示例1: zerocross_interrupt

static void zerocross_interrupt(FAR const struct zc_lowerhalf_s *lower,
                                FAR void *arg)
{
  FAR struct zc_upperhalf_s *priv = (FAR struct zc_upperhalf_s *)arg;
  FAR struct zc_open_s *opriv;
  irqstate_t flags;

  /* This routine is called both task level and interrupt level, so
   * interrupts must be disabled.
   */

  flags = enter_critical_section();

  /* Update sample value */

  sample++;

  /* Visit each opened reference and notify a zero cross event */

  for (opriv = priv->zu_open; opriv; opriv = opriv->do_flink)
    {
      /* Signal the waiter */

#ifdef CONFIG_CAN_PASS_STRUCTS
      union sigval value;
      value.sival_int = (int)sample;
      (void)sigqueue(opriv->do_pid, opriv->do_notify.zc_signo, value);
#else
      (void)sigqueue(opriv->do_pid, opriv->do_notify.zc_signo,
                     (FAR void *)sample);
#endif
    }

  leave_critical_section(flags);
}
开发者ID:acassis,项目名称:ros2_nuttx,代码行数:35,代码来源:zerocross.c


示例2: rtc_alarm_callback

static void rtc_alarm_callback(FAR void *priv, int alarmid)
{
	FAR struct rtc_upperhalf_s *upper = (FAR struct rtc_upperhalf_s *)priv;
	FAR struct rtc_alarminfo_s *alarminfo;

	DEBUGASSERT(upper != NULL && alarmid >= 0 &&
					alarmid < CONFIG_RTC_NALARMS);
	alarminfo = &upper->alarminfo[alarmid];

	/*
	 * Do we think that the alaram is active?  It might be due to some
	 * race condition between a cancellation event and the alarm
	 * expiration.
	 */

	if (alarminfo->active) {
		/* Yes.. signal the alarm expriration */

#ifdef CONFIG_CAN_PASS_STRUCTS
		(void)sigqueue(alarminfo->pid, alarminfo->signo,
				alarminfo->sigvalue);
#else
		(void)sigqueue(alarminfo->pid, alarminfo->signo,
				alarminfo->sigvalue->sival_ptr);
#endif
	}

	/* The alarm is no longer active */

	alarminfo->active = false;
}
开发者ID:tool3210,项目名称:TizenRT,代码行数:31,代码来源:rtc.c


示例3: stress_sigq

/*
 *  stress_sigq
 *	stress by heavy sigqueue message sending
 */
static int stress_sigq(const args_t *args)
{
	pid_t pid;

	if (stress_sighandler(args->name, SIGUSR1, stress_sigqhandler, NULL) < 0)
		return EXIT_FAILURE;

again:
	pid = fork();
	if (pid < 0) {
		if (g_keep_stressing_flag && (errno == EAGAIN))
			goto again;
		pr_fail_dbg("fork");
		return EXIT_FAILURE;
	} else if (pid == 0) {
		sigset_t mask;

		(void)setpgid(0, g_pgrp);
		stress_parent_died_alarm();

		(void)sigemptyset(&mask);
		(void)sigaddset(&mask, SIGUSR1);

		while (g_keep_stressing_flag) {
			siginfo_t info;
			if (sigwaitinfo(&mask, &info) < 0)
				break;
			if (info.si_value.sival_int)
				break;
		}
		pr_dbg("%s: child got termination notice\n", args->name);
		pr_dbg("%s: exited on pid [%d] (instance %" PRIu32 ")\n",
			args->name, (int)getpid(), args->instance);
		_exit(0);
	} else {
		/* Parent */
		union sigval s;
		int status;

		do {
			(void)memset(&s, 0, sizeof(s));
			s.sival_int = 0;
			(void)sigqueue(pid, SIGUSR1, s);
			inc_counter(args);
		} while (keep_stressing());

		pr_dbg("%s: parent sent termination notice\n", args->name);
		(void)memset(&s, 0, sizeof(s));
		s.sival_int = 1;
		(void)sigqueue(pid, SIGUSR1, s);
		(void)shim_usleep(250);
		/* And ensure child is really dead */
		(void)kill(pid, SIGKILL);
		(void)shim_waitpid(pid, &status, 0);
	}

	return EXIT_SUCCESS;
}
开发者ID:ColinIanKing,项目名称:stress-ng,代码行数:62,代码来源:stress-sigq.c


示例4: pthread_condtimedout

static void pthread_condtimedout(int argc, uint32_t pid, uint32_t signo)
{
#ifdef HAVE_GROUP_MEMBERS

  FAR struct tcb_s *tcb;
  siginfo_t info;

  /* The logic below if equivalent to sigqueue(), but uses sig_tcbdispatch()
   * instead of sig_dispatch().  This avoids the group signal deliver logic
   * and assures, instead, that the signal is delivered specifically to this
   * thread that is known to be waiting on the signal.
   */

  /* Get the waiting TCB.  sched_gettcb() might return NULL if the task has
   * exited for some reason.
   */

  tcb = sched_gettcb((pid_t)pid);
  if (tcb)
    {
      /* Create the siginfo structure */

      info.si_signo           = signo;
      info.si_code            = SI_QUEUE;
      info.si_errno           = ETIMEDOUT;
      info.si_value.sival_ptr = NULL;
#ifdef CONFIG_SCHED_HAVE_PARENT
      info.si_pid             = (pid_t)pid;
      info.si_status          = OK;
#endif

      /* Process the receipt of the signal.  The scheduler is not locked as
       * is normally the case when this function is called because we are in
       * a watchdog timer interrupt handler.
       */

      (void)sig_tcbdispatch(tcb, &info);
    }

#else /* HAVE_GROUP_MEMBERS */

  /* Things are a little easier if there are not group members.  We can just
   * use sigqueue().
   */

#ifdef CONFIG_CAN_PASS_STRUCTS
  union sigval value;

  /* Send the specified signal to the specified task. */

  value.sival_ptr = NULL;
  (void)sigqueue((int)pid, (int)signo, value);
#else
  (void)sigqueue((int)pid, (int)signo, NULL);
#endif

#endif /* HAVE_GROUP_MEMBERS */
}
开发者ID:rohiniku,项目名称:NuttX-nuttx,代码行数:58,代码来源:pthread_condtimedwait.c


示例5: control_thread

void* control_thread(void *thid_arr)
{
	int thid = 0, i;
	union sigval data;
	sigset_t set, set1, set2;
	struct timeval tp;

	sigemptyset(&set);
	for(i = SIGRTMIN; i <= SIGRTMAX; i++)
		sigaddset(&set, SIGRTMIN);

	pthread_sigmask(SIG_BLOCK, &set, NULL);
	printf("Inside control thread\n");
	sleep(10);
	//cpu_bind(0);	

	while(1)
	{
		if(!Scheduler_Data.polling_thread_count)
			continue;

		pid_t process_id = Scheduler_Data.process_list[thid];
		unsigned long share_unit = Scheduler_Data.share_unit[thid];
		int signum = Scheduler_Data.signal_num[thid];

		sigset_t polling_thread_set;
		sigemptyset(&polling_thread_set);
		sigaddset(&polling_thread_set, signum);

		if(process_id != INVALID_PROCEESS)
		{
			gettimeofday(&tp, NULL); 
			fprintf(stderr, "control thread starting process id: %d, signum: %d, share_unit:%lu time:%d sec %d usec\n", process_id, signum, share_unit, tp.tv_sec, tp.tv_usec);
	 
			//data.sival_ptr = (void *)(&polling_thread_set);
			data.sival_int = signum;
			sigqueue(process_id, signum, data);
		}
		thid++;
		if(thid > Scheduler_Data.polling_thread_count-1)
			thid = 0;

		if(process_id != INVALID_PROCEESS)
		{
			sleep(share_unit/10);
			//data.sival_ptr = (void *)(&polling_thread_set);
			gettimeofday(&tp, NULL); 
			fprintf(stderr, "control thread sleeping process id: %d, signum: %d, share_unit:%lu time:%d sec %d usec\n", process_id, signum, share_unit, tp.tv_sec, tp.tv_usec);
	 
			data.sival_int = signum;
			sigqueue(process_id, signum, data);   
		}
	}
	return NULL;
}
开发者ID:dipanjans12,项目名称:GVirt,代码行数:55,代码来源:scheduler.c


示例6: lio_sighandler

static void lio_sighandler(int signo, siginfo_t *info, void *ucontext)
{
	FAR struct aiocb *aiocbp;
	FAR struct lio_sighand_s *sighand;
	int ret;

	DEBUGASSERT(signo == SIGPOLL && info);

	/* The info structure should contain a pointer to the AIO control block */

	aiocbp = (FAR struct aiocb *)info->si_value.sival_ptr;
	DEBUGASSERT(aiocbp && aiocbp->aio_result != -EINPROGRESS);

	/* Recover our private data from the AIO control block */

	sighand = (FAR struct lio_sighand_s *)aiocbp->aio_priv;
	DEBUGASSERT(sighand && sighand->list);
	aiocbp->aio_priv = NULL;

	/* Prevent any asynchronous I/O completions while the signal handler runs */

	sched_lock();

	/* Check if all of the pending I/O has completed */

	ret = lio_checkio(sighand->list, sighand->nent);
	if (ret != -EINPROGRESS) {
		/* All pending I/O has completed */
		/* Restore the signal handler */

		(void)sigaction(SIGPOLL, &sighand->oact, NULL);

		/* Restore the sigprocmask */

		(void)sigprocmask(SIG_SETMASK, &sighand->oprocmask, NULL);

		/* Signal the client */

		if (sighand->sig->sigev_notify == SIGEV_SIGNAL) {
#ifdef CONFIG_CAN_PASS_STRUCTS
			(void)sigqueue(sighand->pid, sighand->sig->sigev_signo, sighand->sig->sigev_value);
#else
			(void)sigqueue(sighand->pid, sighand->sig->sigev_signo, sighand->sig->sigev_value.sival_ptr);
#endif
		}

		/* And free the container */

		lib_free(sighand);
	}

	sched_unlock();
}
开发者ID:drashti304,项目名称:TizenRT,代码行数:53,代码来源:lio_listio.c


示例7: main

main()
{
	pid_t pid;
	if(pid=fork()){
		/*父进程:找素数*/
		int a=2;
		int b=100000;
		int i;
		int status;
		union sigval val;
		sched_yield();/*放弃当前执行机会,排到队尾*/
		sleep(1);
		for(i=a;i<b;i++){
			if(IsPrimer(i)){
				/*是素数:发信号给子进程35*/
				val.sival_int=i;
				sigqueue(pid,35,val);/*发送信号给子进程*/
				usleep(1000);
			}
		}
		/*素数查找完毕,通知子进程结束:35*/
		val.sival_int=-1;/*-1:素数查找*/
		sigqueue(pid,35,val);
		wait(&status);/*等待子进程结束*/
		printf("结束!\n");
		exit(0);/*父进程退出*/
	}
	else{
		/*子进程:找孪生素数*/
		struct sigaction  act={0};
		act.sa_sigaction=handle;
		sigemptyset(&act.sa_mask);
		sigfillset(&act.sa_mask);
		act.sa_flags=SA_SIGINFO;		
		sigaction(35,&act,NULL);/*信号处理*/

		sigemptyset(&sigs);
		sigemptyset(&sigsus);
		sigaddset(&sigs,2);
		sigaddset(&sigs,35);
				
		/*屏蔽2信号*/
		sigprocmask(SIG_BLOCK,&sigs,NULL);
		while(1){			
			sigsuspend(&sigsus);/*等待父进程发送的信号*/
		}
		sigprocmask(SIG_UNBLOCK,&sigs,NULL);
	}
}
开发者ID:jimodb,项目名称:codes,代码行数:49,代码来源:sig.c


示例8: sigqueue

// returns 0 on success, -1 on permanent failure, 1 on temporary failure
int
LLHeartbeat::rawSend()
{
#if LL_WINDOWS
	return 0; // Pretend we succeeded.
#else
	if (mSuppressed)
		return 0; // Pretend we succeeded.

	int result;
#ifndef LL_DARWIN
	union sigval dummy;
	result = sigqueue(getppid(), LL_HEARTBEAT_SIGNAL, dummy);
#else
	result = kill(getppid(), LL_HEARTBEAT_SIGNAL);
#endif
	if (result == 0)
		return 0; // success

	int err = errno;
	if (err == EAGAIN)
		return 1; // failed to queue, try again

	return -1; // other failure.
#endif
}
开发者ID:AlchemyDev,项目名称:Carbon,代码行数:27,代码来源:llheartbeat.cpp


示例9: main

int
main(int argc, char *argv[])
{
    int sig, numSigs, j, sigData;
    union sigval sv;

    if (argc < 4 || strcmp(argv[1], "--help") == 0)
        usageErr("%s pid sig-num data [num-sigs]\n", argv[0]);

    /* Display our PID and UID, so that they can be compared with the
       corresponding fields of the siginfo_t argument supplied to the
       handler in the receiving process */

    printf("%s: PID is %ld, UID is %ld\n", argv[0],
            (long) getpid(), (long) getuid());

    sig = getInt(argv[2], 0, "sig-num");
    sigData = getInt(argv[3], GN_ANY_BASE, "data");
    numSigs = (argc > 4) ? getInt(argv[4], GN_GT_0, "num-sigs") : 1;

    for (j = 0; j < numSigs; j++) {
        sv.sival_int = sigData + j;
        if (sigqueue(getLong(argv[1], 0, "pid"), sig, sv) == -1)
            errExit("sigqueue %d", j);
    }

    exit(EXIT_SUCCESS);
}
开发者ID:nipra,项目名称:see,代码行数:28,代码来源:t_sigqueue.c


示例10: main

int main(){
	//sigqueue发送信号,sigaction处理信号	
	struct sigaction action;
	action.sa_sigaction = fa;
	action.sa_flags = SA_SIGINFO;

	sigaction(40,&action,NULL);

	pid_t pid = fork();
	if(-1 == pid){
		perror("fork");
		exit(0);
	}
	if(pid == 0){
		printf("child %d starts to run\n",getpid());
		union sigval value;
		int i = 0;
		for(i = 0;i<10;i++){
			value.sival_int=i;
			sigqueue(getppid(),40,value);
			//直接传入结构体的变量名即可
		}
		exit(0);
	}
	while(1);
	return 0;
}
开发者ID:SamsonWang,项目名称:Study,代码行数:27,代码来源:06sigqueue.c


示例11: main

int main(int argc,char **argv){
	
	//char str[100] = {0};
	int sig2;
	pid_t sig1;
	union sigval val;
		sig2 = atoi(argv[2]);
	sig1 =(pid_t) atoi(argv[1]);

	while(1){
	//sprintf(str,"kill -s %s %s","sig1","sig2");
	sigqueue(sig1,sig2,val);
	//system(str);
	sleep(3);
	}



	//int sigqueue(pid_t pid, int sig, const union sigval val)





	return 0;
}
开发者ID:yinuo,项目名称:AA,代码行数:26,代码来源:sig3.c


示例12: main

int main(void)
{

	union sigval value;
	value.sival_int = 0;	/* 0 is just an arbitrary value */

	/* We assume process Number 1 is created by root */
	/* and can only be accessed by root */
	/* This test should be run under standard user permissions */
	if (getuid() == 0) {
		if (set_nonroot() != 0) {
			printf("Cannot run this test as non-root user\n");
			return PTS_UNTESTED;
		}
	}

	if (sigqueue(1, 0, value) != -1) {
		printf
		    ("Test FAILED: sigqueue() succeeded even though this program's user id did not match the recieving process's user id\n");
		return PTS_FAIL;
	}

	if (EPERM != errno) {
		printf("Test FAILED: EPERM error not received\n");
		return PTS_FAIL;
	}

	return PTS_PASS;
}
开发者ID:mmlr,项目名称:open-posix-testsuite,代码行数:29,代码来源:3-1.c


示例13: main

int main()
{
	int pid;
	union sigval value;
	struct sigaction act;

	act.sa_flags = SA_SIGINFO;
	act.sa_sigaction = myhandler;
	sigemptyset(&act.sa_mask);
	sigaction(SIGTOTEST, &act, 0);

	value.sival_int = 0;	/* 0 is just an arbitrary value */
	pid = getpid();

	if ((return_val = sigqueue(pid, SIGTOTEST, value)) != 0) {
		printf("Test UNRESOLVED: call to sigqueue did not return success\n");
		return PTS_UNRESOLVED;
	}

	if (handler_called != 1) {
		printf("Test FAILED: signal was not delivered to process\n");
		return PTS_FAIL;
	}
	return PTS_PASS;
}
开发者ID:Mellanox,项目名称:arc_ltp,代码行数:25,代码来源:6-1.c


示例14: qos_SignalQueOld

pwr_tStatus
qos_SignalQueOld (
  pwr_tStatus	*status,
  qdb_sQue	*qp
)
{
  union sigval	value;
  int		ok;
  pwr_dStatus	(sts, status, QCOM__SUCCESS);

  qdb_AssumeLocked;

  if (qp->lock.waiting) {
//    value.sival_int = BUILDPID(getpid(), pthread_self());
    value.sival_int = getpid();
    qp->lock.waiting = FALSE;

    ok = sigqueue(qp->lock.pid, qdb_cSigMsg, value);

    if (ok == -1) {
      *sts = errno_Status(errno);
    }
  }

  return TRUE;
}
开发者ID:Strongc,项目名称:proview,代码行数:26,代码来源:rt_qos.c


示例15: main

int main (int argc, char *argv[])
{
    struct sigaction act;
    struct my_s s;
    int j, sig = SIGALRM;
    union sigval sv;

    if (argc > 1)
        sig = atoi (argv[1]);

    memset (&act, 0, sizeof (act));
    act.sa_sigaction = sig_act;
    act.sa_flags = SA_SIGINFO;
    if (sigaction (sig, &act, NULL) < 0)  
        DEATH ("sigaction");

    printf ("pid=%d Successfully installed signal handler for signal=%d\n",
            getpid (), sig);

    for (j = 0; j < 3; j++) {
        printf ("This is a pointless message\n");
        s.x = j * 100;
        strcpy (s.s, "hello buddy");
        sv.sival_ptr = &s;
        printf ("sigqueue returns %d\n",sigqueue (getpid (), sig, sv));
        sleep (1);
    }
    exit (0);
}
开发者ID:charan678,项目名称:snippets,代码行数:29,代码来源:siginfo.c


示例16: main

int main()
{
	int result = 0;
	sigset_t waitset;
	siginfo_t info;
	pid_t cpid;
	union sigval val;

	/* let's disable async handlers and enable signal queue */
	sigemptyset(&waitset);
	sigaddset(&waitset, SIGRTMIN);
	sigprocmask(SIG_BLOCK, &waitset, NULL);
	
	cpid = fork();
	if (cpid == 0) {
		printf("child pid %d\n", getpid());
		timestamp("before sigwaitinfo()");
		/* wait for signal to arrive */
		result = sigwaitinfo(&waitset, &info);
		if (result < 0)
			printf("sigwaitinfo failed : \n");
		/* got signal */
		printf("sigwaitinfo() returned for signal %d\n", info.si_signo);
		timestamp("after sigwaitinfo()");
		exit(0);
	} else {
		val.sival_int = 0;
		sigqueue(cpid, SIGRTMIN, val);
		waitpid(cpid, NULL, 0);
//              printf("end of program \n");
		while (1) ;
	}
	return 0;
}
开发者ID:md-jamal,项目名称:Linuxpro,代码行数:34,代码来源:sigcom.c


示例17: SendMessageToHALos

void SendMessageToHALos ()
{
    ofstream ioResponseFile;
    union sigval dummyValue;

    ioResponseFile.open ("HALdisplayDriverToHALos");
    if (!ioResponseFile)
    {
        cout << "HALdisplayDriver: unable to initialize io response buffer" << endl;
        return;
    }

    ioResponseFile << "INTERRUPT" << endl;
    ioResponseFile << "DISPLAY_DRIVER" << endl;
    ioResponseFile << pid << endl;
    ioResponseFile << result << endl;

    ioResponseFile.close ();

    if (sigqueue (HALosPid, SIGRTMIN, dummyValue) == -1)
    {
        cout << "HALdisplayDriver: io response signal not sent to HALos" << endl;
        exit (1);
    }

    return;
}
开发者ID:JordanSelinger,项目名称:CS330,代码行数:27,代码来源:HALdisplayDriver.cpp


示例18: main

int main(int argc, char** argv)
{
	int sig;
	int numSigs;
	int j;
	int sigData;
	
	union sigval sv;
	if (5 != argc)
	{
		log_info("usage:%s pid sig-num data [num-sigs]\n", argv[0]);
		return -1;
	}
	
	log_info("%s: pid is %ld, uid is %ld\n", argv[0], getpid(), getuid());
	sig = atoi(argv[2]);
	sigData = atoi(argv[3]);
	numSigs = atoi(argv[4]);
	pid_t pid = atoi(argv[1]);
	for (j=0; j<numSigs; ++j)
	{
		sv.sival_int = sigData + 1;
		if (sigqueue(pid, sig, sv) < 0)
		{
			log_info("sigqueue fail\n");
			return -1;
		}	
	}	
	return 0;
}
开发者ID:yfchenggithub,项目名称:APUE,代码行数:30,代码来源:queue_signal.c


示例19: send_interrupt

void send_interrupt(int interrupt_type, interrupt_handler_t handler, void* arg){

    interrupt_t interrupt;
    pthread_mutex_lock(&signal_mutex);
    for (;;){
        signal_handled = 0;

        interrupt.arg = arg;
        if(interrupt_type==NETWORK_INTERRUPT_TYPE)
            interrupt.handler = mini_network_handler;
        else if(interrupt_type==READ_INTERRUPT_TYPE)
            interrupt.handler = mini_read_handler;
        else
            abort();

        /* Repeat if signal is not delivered. */
        while(sigqueue(getpid(),SIGRTMAX-2, (union sigval)(void*)&interrupt)==-1);

        /* semaphore_P to wait for main thread signal */
        sem_wait(&interrupt_received_sema);

        /* Check if interrupt was handled */
        if(signal_handled)
            break;

        sleep(0);
        /* resend if necessary */
    }
    pthread_mutex_unlock(&signal_mutex);
}
开发者ID:DolphinWilly,项目名称:PortOSnix,代码行数:30,代码来源:interrupts.c


示例20: main

int main(void)
{
	int failure = 0;
	union sigval value;
	value.sival_int = 0;	/* 0 is just an arbitrary value */

	/*
	 * ESRCH
	 */
	if (-1 == sigqueue(999999, 0, value)) {
		if (ESRCH == errno) {
			printf("ESRCH error received\n");
		} else {
			printf
			    ("sigqueue() failed on ESRCH but errno not set correctly\n");
			failure = 1;
		}
	} else {
		printf("sigqueue() did not return -1 on ESRCH\n");
		failure = 1;
	}

	if (failure) {
		printf("At least one test FAILED -- see output for status\n");
		return PTS_FAIL;
	} else {
		printf("All tests PASSED\n");
		return PTS_PASS;
	}
}
开发者ID:1587,项目名称:ltp,代码行数:30,代码来源:2-2.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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