-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path011.c
More file actions
45 lines (35 loc) · 1.17 KB
/
Copy path011.c
File metadata and controls
45 lines (35 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/*
..........................................................................................................................................
Name : 011.c
Author : SHRUTI VERMA
Description : Write a program to ignore a SIGINT signal then reset the default action of the SIGINT signal -
use sigaction system call.
Date : 20 Sep 2025
..........................................................................................................................................
*/
#include<unistd.h>
#include<stdio.h>
#include<stdlib.h>
#include<signal.h>
void my_handler(int signal) {
printf("Caught SIGINT : Interrupt from Keyboard\n");
}
int main() {
struct sigaction sa;
sa.sa_handler = my_handler;
sa.sa_flags = 0;
printf("press Ctrl + C to exit\n");
sigaction(SIGINT, &sa, NULL);
pause();
sa.sa_handler = SIG_DFL;
printf("press Ctrl + C to exit again\n");
sigaction(SIGINT, &sa, NULL);
pause();
return 0;
}
/*----------------------------------OUTPUT----------------------------------------------------------------
press Ctrl + C to exit
^CCaught SIGINT : Interrupt from Keyboard
press Ctrl + C to exit again
^C
*/