Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

signal SIGINT

Status
Not open for further replies.

nnair

Technical User
May 22, 2002
4
IN
Hi,
Given below is a sample pgm which I read in a book. Acc, to the book, this pgm should call function ‘abc’ the 1st time Ctrl^C is pressed & when Ctrl^C is pressed 2nd time it should terminate the pgm. But when I tried executing the same pgm in Linux, every time, Ctrl^C was pressed, the pgm called ‘abc’ function & went in infinite loop.
Could anyone tell me why did this happen & what is the default beavior?

#include<signal.h>

void abc();
main()
{
printf(“Press Key\n”);
signal(SIGINT,abc);
for(;;);
}

void abc()
{
printf(“U have pressed the key”):
}

Thanx,
N
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top