1 // This testcase, when run with large number of threads
2 // under stace -f, may never finish because strace does not
3 // ensure any fairness in thread scheduling:
4 // it restarts threads as they stop. If daughter threads crowd out
5 // the "mother" and _they_ get continually restarted by strace,
6 // the end of spawning loop will never be reached.
8 // Also, it is a testcase which triggers the
9 // "strace: Exit of unknown pid 32457 seen"
10 // message when on testcase exit, strace sees deaths of newly-attached
11 // threads _before_ their first syscall stop.
16 #include <sys/types.h>
22 static void *sub_thd(void *c)
24 dprintf(1, "sub-thread %d created\n", ++thd_no);
30 int main(int argc, char *argv[])
37 num_threads = atoi(argv[1]);
39 thd = malloc(num_threads * sizeof(thd[0]));
40 dprintf(1, "test start, num_threads:%d...\n", num_threads);
42 for (i = 0; i < num_threads; i++) {
43 pthread_create(&thd[i], NULL, sub_thd, NULL);
44 dprintf(1, "after pthread_create\n");
47 /* Exit. This kills all threads */