[Signaux] et segfaults ;)
Alors voila, je m entrainais avec les signaux et je bute sur un probleme apparemment vraiment bete : voila
tfe@sd1510:~/projet_se_sd$ gcc test.c -o test
tfe@sd1510:~/projet_se_sd$ ./test &
[2] 10815
tfe@sd1510:~/projet_se_sd$ kill -10 10815
tfe@sd1510:~/projet_se_sd$ Youpi
[2]+ Segmentation fault ./test
Code:
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
| #include <stdio.h>
#include <stdlib.h>
#include <signal.h>
void fonction(int n)
{
printf("Youpi\n");
}
int main()
{
struct sigaction action;
action.sa_handler = fonction;
sigemptyset(&action.sa_mask);
if(sigaction(SIGUSR1, &action, NULL) == -1)
{
perror("sigction");
exit(-1);
}
while(1) { pause(); }
printf("OK");
return 0;
} |
une idée ?