title: Implementing a WatchDog timer
body: <p>I need to implement a timer that checks for conditions every 35 seconds. My program is using IPC schemes to communicate information back and forth between client and server processes. The problem is that I am running msgrcv() function in a loop, which pauses the loop until it finds a message, which is no good because I need the timer to always be checking if a client has stopped sending messages. (if it only checks when it receives a message, this will be useless...)</p>
  
  <p>The problem may seem unclear, but the basics of what I need is a way to implement a Watchdog timer that will check a condition every 35 seconds.</p>
  
  <p>I currently have this code:</p>
  
  <pre><code>time_t start = time(NULL);
  
  //Enter main processing loop
  while(running)
  {
      size_t size = sizeof(StatusMessage) - sizeof(long);
  
      if(msgrcv(messageID, &amp;statusMessage, size, 0, 0) != -1)
      {
          printf("(SERVER) Message Data (ID #%ld)  =  %d  :  %s\n", statusMessage.machineID, statusMessage.status_code, statusMessage.status);
  
          masterList-&gt;msgQueueID = messageID;
          int numDCs = ++masterList-&gt;numberOfDCs;
  
          masterList-&gt;dc[numDCs].dcProcessID = (pid_t) statusMessage.machineID;
          masterList-&gt;dc[numDCs].lastTimeHeardFrom = 1000;
  
          printf("%d\n", masterList-&gt;numberOfDCs);
      }
  
      printf("%.2f\n", (double) (time(NULL) - start));
  }
  </code></pre>
  
  <p>The only problem is as I stated before, the code to check how much time has passed, won't be reached if there is no message to come in, as the msgrcv function will hold the process.</p>
  
  <p>I hope I am making sense, and that someone will be able to assist me in my problem.</p>