Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
bgColor#ffcccc
langc
#include <signal.h>

sig_atomic_t interrupted;   /* Bug: not declared volatile */

void sigint_handler(int signum) {
  interrupted = 1;   /* Assignment may not be visible in main(). */
}

int main(void) {
  signal(SIGINT, sigint_handler);
  while (!interrupted) {   /* Loop may never terminate. */
   /* Do something */
  }
  return 0;
}

...