Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在发送到消息队列(C)后向另一进程发送SIGIO信号_C_Signals_Message Queue - Fatal编程技术网

在发送到消息队列(C)后向另一进程发送SIGIO信号

在发送到消息队列(C)后向另一进程发送SIGIO信号,c,signals,message-queue,C,Signals,Message Queue,我正在编写一个任务,其中一个进程(发送方)应该使用消息队列向另一个进程(接收方)发送消息。分配说明接收方不应阻塞或轮询队列,而是发送方应在向队列发送消息后向接收方发送SIGIO 我的问题是我不知道怎么做。我确信问题不在于队列,而在于接收端的信号处理程序或发送端的SIGIO 这是在计时器上调用的发送方代码: /*code for sending a message, works as intended*/ /*code below is questionable*/ //msqid is the

我正在编写一个任务,其中一个进程(发送方)应该使用消息队列向另一个进程(接收方)发送消息。分配说明接收方不应阻塞或轮询队列,而是发送方应在向队列发送消息后向接收方发送SIGIO

我的问题是我不知道怎么做。我确信问题不在于队列,而在于接收端的信号处理程序或发送端的SIGIO

这是在计时器上调用的发送方代码:

/*code for sending a message, works as intended*/
/*code below is questionable*/
//msqid is the message queue id; I'm guessing that's the file descriptor I want.
fcntl(msqid, F_SETOWN, receiver_pid); //designates receiver as the process to send the signal too?
int flags;
flags = fcntl(msqid, F_GETFL); //save flags
fcntl(msqid, F_SETFL, flags | O_ASYNC); //set flag that sends SIGIO?
这是在receiver的主要功能中设置的信号处理程序(格式是从确实有效的报警处理程序复制的,因此我认为这是正确的):

最后,接收方在等待消息时调用pause()

  while (pkt_cnt < pkt_total) {
  pause(); /* block until next packet */
  }
while(pkt\u cnt
当我运行这段代码时,结果是所有消息都放在队列中,但接收方中的信号处理程序从不触发


如何根据发送方的操作触发接收器中的信号处理程序?

人工杀伤
:“杀伤-向进程发送信号…”谢谢,这很有效。在我的搜索过程中,我挂断了使用SIGIO的电话,这导致了fcntl。
  while (pkt_cnt < pkt_total) {
  pause(); /* block until next packet */
  }