Polling timer function in C
What is a reason for using alarm() with sleep()? Why not just

void sigIntHandler(int signum) {
  fprintf(stdout, "received interrupt. going to exit.\n");
  exit(0);
}

int main(int argc, char* argv[]) {
  if(initializeEnvironment(argc, argv) == -1) {
    return -1;
  }
  signal(SIGINT, signalAlarmHandler); /* for testing purposes */

  while(1) {
    sleep(10);
    /* checking for condition here */
  }
}


Also:


fprintf() is not signal-safe, better not to use it from signal handler
signal() is obsolete and implementation-dependent, use sigaction() for consistent results.