return to first page linux journal archive
keywordscontents

Listing 4. sigusr1_handler, Common Interrupt Service Routine

void sigusr1_handler(int s)
{
  struct timeval tv;
  int  max_fd, error, value=0;
  int get_highest();
  fd_set pipes;
  pipes=set_of_pipes; max_fd = get_highest();
/* "get_highest()" gets the highest file
    descriptor number among all the pipes
    contained in "set_of_pipes" */
  while (value == 0) {
    tv.tv_sec = 1;
    tv.tv_usec = 0;
    value = select(max_fd+1, &pipes,
                   NULL, NULL,
                   &tv);
  }
/* Search for the file descriptor guilty of
   the signal's generation, and CALL the
   ROUTINE.  "error" is true if an alert was
   received.  If an interrupting process fails
   fatally, it should send an alert (write "!"
   to its pipe).  */ 
  error = scanlist(pipes);
}