regtest: broaden none/tests/linux/bug498317 suppression for PPC
[valgrind.git] / none / tests / pth_2sig.c
blob31cd710ce993651304742f7be129127ae9d8e26f
1 #include <pthread.h>
2 #include <signal.h>
3 #include <stdlib.h>
4 #include <stdio.h>
5 #include <string.h>
6 #include <unistd.h>
7 #include <sys/wait.h>
9 void *slavethread(void *arg)
11 while (1)
12 pause();
15 int main(int argc, char **argv)
17 const struct timespec alittle = { 0, 1000000000 / 100 }; // 0.01 seconds.
18 int i;
19 for (i = 0; i < 10; i++) {
20 pthread_t slave;
21 if (pthread_create(&slave, 0, slavethread, 0)) {
22 perror("pthread_create");
23 exit(2);
27 pid_t pid = getpid();
28 switch (fork()) {
29 case 0: // child
30 sleep(2); // Should be enough to ensure (some) threads are created
31 for (i = 0; i < 20 && kill(pid, SIGTERM) == 0; i++)
32 nanosleep(&alittle, NULL);
33 exit(0);
34 case -1:
35 perror("fork");
36 exit(4);
39 while (1)
40 pause();
41 fprintf(stderr, "strange, this program is supposed to be killed!\n");
42 return 1;