#include
#include
void handler(int signo)
{
printf(\"Into handler\\n\");
while(1);
}
int main()
{
struct sigaction act;
Using the printf
function within a signal handler is not exactly a good idea to use as it can cause behavior that is undefined! The code sample is missing a vital bit for the signal handler to work....Have a look at my blog about this here on 'Q6. How to trap a Segmentation fault?'
Also, you need to replace the while
loop with something more robust as a way to quit the program while testing the signal handler...like...how do you quit it?