title: Sending a SIGIO signal to another process after sending to a message queue (C)
body: <p>I'm writing an assignment where one process (the sender) is supposed to send messages to another process (the receiver) using a message queue. The assignment states that Receiver should not block or poll the queue, but rather Sender should SIGIO to the Receiver after sending a message to the queue.</p>
  
  <p>My problem is that I do not know how to do this. I'm sure the problem isn't with the queue, but either the signal handler on Receiver's end or sending SIGIO on sender's end.</p>
  
  <p>This is sender's code, which is called on a timer:</p>
  
  <pre><code>/*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?
  </code></pre>
  
  <p>This is the signal handler set up in the main function of receiver (the format is copied from an alarm handler that does work, so I think this is right):</p>
  
  <pre><code>struct sigaction act;
  memset(&amp;act, 0, sizeof(act)); //clear it
  act.sa_handler = &amp;packet_handler;
  if (sigaction(SIGIO, &amp;act, NULL) == -1)
  {
  perror("Error setting up SIGIO handler");
  }
  </code></pre>
  
  <p>And finally the receiver calls pause() while it waits for messages.</p>
  
  <pre><code>  while (pkt_cnt &lt; pkt_total) {
    pause(); /* block until next packet */
    }
  </code></pre>
  
  <p>The result when I run this code is that all the messages get put on the queue, but the signal handler in receiver never triggers.</p>
  
  <p>How do I trigger the signal handler in Receiver based on the actions of Sender?</p>