
#include <stdio.h>
#include <unistd.h>    /* standard unix functions, like getpid()         */
#include <signal.h>    /* signal name macros, and the signal() prototype */
#include <stdlib.h>

// check out
// man kill
// kill -l


void catchSignal(int signal){
  if(signal == SIGINT)
    printf("It is not polite to interupt.\n");
  else if(signal == SIGTERM){
    printf("I will not yield!\n");
    //exit(0);
  }
}

int main(){
  signal(SIGINT, catchSignal);
  signal(SIGTERM, catchSignal);
  //mention SIGHUP for when the terminal closes

  char *line = NULL;
  size_t size = 0;
  for(;;){
    //pause();  //do nothing but wait for signals
    //printf("Continuing...\n");
    printf("Type something: ");
    getline(&line, &size, stdin);

    printf("You typed %s.\n", line);
    free(line);
    line = NULL;
  }
}
