Featured Post

Tuesday, May 10, 2016

UNIX program to demonstrate the use of alarm() pause() and sleep() system calls

#include<stdio.h>
#include<signal.h>
void alarm_handler(int signo)
{
   signal(SIGALRM,alarm_handler);
   printf("the alarm signal handled by the prcess");
}
main()

{
 
 
  printf("alarm set to go off in 15 seconds\n");
  alarm(15);
 signal(SIGALRM,alarm_handler);

  printf("the proces paused for a while \n");
   pause();
   printf("the process is going to sleep for 20 seconds\n");
   sleep(20);
 
}


output:

alarm set to go off in 15 seconds
the alarm signal handled by the process
the process paused for a while
the process is going to sleep for 20 seconds
















signal handling in unix, alarm() pause() sleep() abort() reliable signal handling unreliable singal handling




No comments:

Post a Comment