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

Answers were Sorted based on User's Feedback



c program the catches the ctrl-c(SIGINT) Signal for the first time and prints a output rather and ..

Answer / dwarf

on Linux:
man 2 signal
for signum use SIGINT

Is This Answer Correct ?    0 Yes 0 No

c program the catches the ctrl-c(SIGINT) Signal for the first time and prints a output rather and ..

Answer / 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

More Shell Script Interview Questions

How are shells born?

0 Answers  


How do I edit a .sh file?

0 Answers  


How to declare functions in unix shell script?

4 Answers  


What is the use of echo in shell script?

0 Answers  


What does the sh command do?

0 Answers  






What can scripts do?

0 Answers  


Devise a script that takes file name as arguement(which must present in the current directory)and locates from your home directory tree all thpath names of its links.Then mail the list to self.

0 Answers  


What does $$ mean in shell script?

0 Answers  


How does shell scripting work?

0 Answers  


What is difference between bash and shell?

0 Answers  


How do I open the shell in cmd?

0 Answers  


How would you replace the n character in a file with some xyz?

7 Answers  


Categories