|
@@ -0,0 +1,31 @@
|
|
|
+#define _CRT_SECURE_NO_WARNINGS
|
|
|
+#include <stdio.h>
|
|
|
+#include <string.h>
|
|
|
+#include <stdlib.h>
|
|
|
+#include <unistd.h> //sleep
|
|
|
+#include <signal.h> //сигналы
|
|
|
+
|
|
|
+void handlerSign(int sig)
|
|
|
+{
|
|
|
+ switch (sig)
|
|
|
+ {
|
|
|
+ case SIGINT: printf("Не мешай мне работать\n");
|
|
|
+ //signal(SIGINT, SIG_DFL);
|
|
|
+ break;
|
|
|
+ case SIGQUIT: printf("Тебе не прервать меня\n");
|
|
|
+ //signal(SIGQUIT, SIG_DFL);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+int main()
|
|
|
+{
|
|
|
+ signal(SIGINT, handlerSign);
|
|
|
+ signal(SIGQUIT, handlerSign);
|
|
|
+ while (1)
|
|
|
+ {
|
|
|
+ printf("Я работаю\n");
|
|
|
+ sleep(1);
|
|
|
+ }
|
|
|
+ return 0;
|
|
|
+}
|