All pastes #746157 Raw Edit

some junk

public text v1 · immutable
·published 2007-10-23 00:00 UTC
rendered paste body
#include <signal.h>
#include <stdio.h>
#include <unistd.h>

static int alarm_fired = 0;

void ding(int sig)
{
  alarm_fired = 1;
  printf("ding....");
}

/*  In main, we tell the child process to wait for five seconds
    before sending a SIGALRM signal to its parent.  */

int main()
{

 printf("waiting for alarm to go off\n");
  (void) signal(SIGINT, ding);

  int i;
  for (i=0;i<15;i++){
    sleep(1);
  }

  if (alarm_fired)
    printf("Ding!\n");

  printf("done\n");
  exit(0);
}