1 /* Test case for C-c sent to threads with pending signals. Before I
2 even get there, creating a thread and sending it a signal before it
3 has a chance to run leads to an internal error in GDB. We need to
4 record that there's a pending SIGSTOP, so that we'll ignore it
5 later, and pass the current signal back to the thread.
7 The fork/vfork case has similar trouble but that's even harder
8 to get around. We may need to send a SIGCONT to cancel out the
9 SIGSTOP. Different kernels may do different things if the thread
10 is stopped by ptrace and sent a SIGSTOP. */
18 /* Loop long enough for GDB to send a few signals of its own, but
19 don't hang around eating CPU forever if something goes wrong during
21 #define NSIGS 10000000
23 pthread_barrier_t barrier
;
31 pthread_t main_thread
;
32 pthread_t child_thread
, child_thread_two
;
39 pthread_barrier_wait (&barrier
);
41 for (i
= 0; i
< NSIGS
; i
++)
42 pthread_kill (child_thread
, SIGUSR1
);
46 thread_function (void *arg
)
50 pthread_barrier_wait (&barrier
);
52 for (i
= 0; i
< NSIGS
; i
++)
53 pthread_kill (child_thread_two
, SIGUSR2
);
60 signal (SIGUSR1
, handler
);
61 signal (SIGUSR2
, handler
);
63 pthread_barrier_init (&barrier
, NULL
, 3);
65 main_thread
= pthread_self ();
66 pthread_create (&child_thread
, NULL
, thread_function
, NULL
);
67 pthread_create (&child_thread_two
, NULL
, child_two
, NULL
);
69 pthread_barrier_wait (&barrier
);
71 for (i
= 0; i
< NSIGS
; i
++)
72 pthread_kill (child_thread_two
, SIGUSR1
);
74 pthread_join (child_thread
, NULL
);