this is modification but the same problem it stucks @ getchar() or scanf(), again after inserting any char except 'y' ,promting it for new input ,after it stuck if the user insert any new char it will exit the signal handler function back to the main()
CODE:
Code:
sig_quit(int signo)
{
//char ans[5];
char ans;
printf("Are you sure want to exit program ?Y/N \n");
//while(check){ check = !scanf("%s", ans); }
//scanf("%c",&ans);
ans=getchar();
//fgets(ans,sizeof(ans),stdin);;
printf("ans is : %c",ans);
if(ans=='y' || ans=='Y')
{
printf("Goodbye\n");
exit(0);
return;
}
else if(ans!='y')
{
printf("why ans is : %c",ans);
}
}