Login
Проблема с Signal-Handlerами
132 просмотров
Перейти к просмотру всей ветки
Chipolino знакомое лицо
in Antwort genocidee 20.10.06 16:48
Может я тебя неправильно понял , но цикл прерывается при запуске исключения .
Или ты хочешь чтоб цикл просто прервался ?
В ответ на:
sig_atomic_t KEEP_RUNNUNG=1;
void my_handler(){
KEEP_RUNNUNG=0;
printf("my_handler\n");
}
int main(){
struct sigaction sa;
memset(&sa,0,sizeof(sa));
sa.sa_handler=&my_handler;
sigaction(SIGUSR1,&sa,NULL);
while(KEEP_RUNNUNG)
{
printf("action 1\n");
raise(SIGUSR1);
printf("action 2\n");
}
return 0;
}
sig_atomic_t KEEP_RUNNUNG=1;
void my_handler(){
KEEP_RUNNUNG=0;
printf("my_handler\n");
}
int main(){
struct sigaction sa;
memset(&sa,0,sizeof(sa));
sa.sa_handler=&my_handler;
sigaction(SIGUSR1,&sa,NULL);
while(KEEP_RUNNUNG)
{
printf("action 1\n");
raise(SIGUSR1);
printf("action 2\n");
}
return 0;
}
Или ты хочешь чтоб цикл просто прервался ?