2.
1
Write a C program using signal function calls as follows: when CTRL C is pressed a
Signal, with message, “Press CTRL Z to terminate” should be sent.
#include <signal.h>
#include <stdio.h>
#include <unistd.h>
void my_handler(int signal)
{
printf("Problem encountered %d \n", signal);
}
int main()
{
(void) signal (SIGINT,my handler);
while(1)
{
printf("press contrl z to terminate \n");
sleep(2);
}
}
2.2
Write a C program using signal function calls as follows: when CTRL C is pressed
the signal should be ignored
#include <signal.h>
#include <stdio.h>
#include <unistd.h>
int main()
{
(void) signal (SIGINT,SIG_IGN);
while(1)
{
printf("%d \n", getpid());
sleep(1);
}
}