Bug 497723 - forgot to restore callgrind output cleanup
[valgrind.git] / none / tests / pth_blockedsig.c
blob58e376db6d710ff60bb418f63c6cd4a3e65274b8
1 #include <stdlib.h>
2 #include <string.h>
3 #include <unistd.h>
4 #include <errno.h>
5 #include <stdio.h>
6 #include <signal.h>
7 #include <pthread.h>
9 static void sig_usr1(int);
11 static pthread_t main_thread;
13 void *
14 child_main(void *no_args)
16 // int i;
18 // Only do it once, to shorten test --njn
19 // for (i = 0; i < 5; ++i)
20 // {
21 sleep (1);
22 fprintf (stdout, "thread CHILD sending SIGUSR1 to thread MAIN\n");
23 if (pthread_kill (main_thread, SIGUSR1) != 0)
24 fprintf (stderr, "error doing pthread_kill\n");
25 // }
27 return no_args;
30 int
31 main(void)
33 struct sigaction sigact;
34 sigset_t newmask, oldmask;
35 pthread_t child;
37 memset(&newmask, 0, sizeof newmask);
38 sigemptyset (&newmask);
39 sigaddset (&newmask, SIGUSR1);
41 if (pthread_sigmask (SIG_BLOCK, &newmask, &oldmask) != 0)
42 fprintf (stderr, "SIG_BLOCK error");
44 memset (&sigact, 0, sizeof sigact);
45 sigact.sa_handler = sig_usr1;
46 if (sigaction(SIGUSR1, &sigact, NULL) != 0)
47 fprintf (stderr, "signal(SIGINT) error");
49 main_thread = pthread_self ();
50 if (pthread_create (&child, NULL, child_main, NULL) != 0)
51 fprintf (stderr, "error creating thread");
53 pthread_join (child, NULL);
55 exit(0);
58 static void
59 sig_usr1 (int signo)
61 fprintf (stderr, "SHOULD NOT BE HERE (SIGUSR1)!!!!\n");
62 return;