Добавил:
Studfiles2
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:Лабораторная работа 1 / lab1 / lab1_sr3
.c#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
void term_handler(int i)
{ printf ("Terminating\n");
exit(EXIT_SUCCESS);
}
int main(int argc, char ** argv) {
struct sigaction sa;
sigset_t newset;
//sigemptyset(&newset);
//sigaddset(&newset, SIGHUP);
//sigprocmask(SIG_BLOCK, &newset, 0);
sigemptyset(&sa.sa_mask);
sa.sa_flags = 0;
//sa.sa_flags = sa.sa_flags | SA_NODEFER | SA_RESETHAND;
sa.sa_handler = term_handler;
//sigaction(SIGTERM, &sa, 0);
sigaction(SIGUSR1, &sa, NULL);
printf("My pid is %i\n", getpid());
printf("Waiting...\n");
while(1) sleep(1);
return EXIT_FAILURE;
}
/*
#define SIGALRM 14
#define SIGTERM 15
#define SIGUNUSED 31
#if defined(__i386__) || defined(__x86_64__) || defined(__powerpc__) || defined(__arm__) \
|| defined(__s390__) || defined(__ia64__) || defined(__powerpc64__)
#define SIGBUS 7
#define SIGUSR1 10
#define SIGUSR2 12
#define SIGSTKFLT 16
#define SIGCHLD 17
#define SIGCONT 18
#define SIGSTOP 19
#define SIGTSTP 20
#define SIGTTIN 21
#define SIGTTOU 22
#define SIGURG 23
#define SIGXCPU 24
#define SIGXFSZ 25
#define SIGVTALRM 26
#define SIGPROF 27
#define SIGWINCH 28
#define SIGIO 29
#define SIGPWR 30
#define SIGSYS 31
*/
Соседние файлы в папке lab1