#include <signal.h>

size_t i;

void handler(void) {
   i = 0;
}

int main(void) {
   signal(SIGINT, handler);

   i = 1;

   while(i) {
      /* do something */
   }
}