aboutsummaryrefslogtreecommitdiff
path: root/semestr-5/so/lista2/test.c
diff options
context:
space:
mode:
Diffstat (limited to 'semestr-5/so/lista2/test.c')
-rw-r--r--semestr-5/so/lista2/test.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/semestr-5/so/lista2/test.c b/semestr-5/so/lista2/test.c
new file mode 100644
index 0000000..64e4166
--- /dev/null
+++ b/semestr-5/so/lista2/test.c
@@ -0,0 +1,33 @@
+#include <signal.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+
+static void signal_handler(int signum) {
+ if (signum == SIGINT) {
+ write(STDOUT_FILENO, "XD\n", 3);
+ _exit(0);
+ }
+}
+
+
+int main() {
+ signal(SIGINT, signal_handler);
+ sigset_t mask;
+ sigemptyset(&mask);
+ sigaddset(&mask, SIGINT);
+ // sigfillset(&mask);
+ // sigdelset(&mask, SIGINT);
+ // sigprocmask(SIG_BLOCK, &mask, NULL);
+ // // int *p = NULL;
+ // // sleep(10);
+ // // *p = 1;
+ // // pause();
+ // // abort();
+ // _exit(0);
+ // printf("Lmao\n");
+ // while(1) {}
+ int sig;
+ sigwait(&mask, &sig);
+ printf("sig: %d\n", sig);
+} \ No newline at end of file