c program the catches the ctrl-c(SIGINT) Signal for the
first time and prints a output rather and exit on pressing
Ctrl-C again

Answer Posted / rakesh

#include <stdio.h>

#include <signal.h>



void sigproc(void);


main()

{


signal(SIGINT, sigproc);


printf("This program catches ctrl-c(SIGINT) signal for
first time and exit on pressing ctrl-c again\n");

for(;;);
/* infinite loop */

}

void sigproc()

{

signal(SIGINT, sigproc);

printf("you have pressed ctrl-c \n");

(void) signal(SIGINT,SIG_DFL);


}

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Is shell scripting a language?

803


How do I run a bin bash script?

790


What are the various stages of a linux process it passes through?

877


What are the advantages of using shell scripts?

834


What is the default ubuntu terminal?

846


What is inside a seashell?

887


How do I save a powershell script?

816


What does $@ mean in shell?

807


How do you create a shortcut in linux?

834


How can you find out how long the system has been running?

714


What is bash used for?

783


How do I run a powershell script?

822


Explain about non-login shell files?

927


What are the two files of crontab command?

895


What is an inode block?

828