2 This test makes sure the thread exit notification signals don't
3 interfere with the stack growth signals.
5 Thread death notifications are sent as RT signals, which are
6 queued. In general, these notifications are ignored, since they're
7 only used by the main thread if it has exited and is still waiting
10 The system has a finite limit to the number of RT signals which can
11 be queued (typically 1024), and beyond that it stops queueing
12 siginfo. We rely on getting SIGSEGVs with siginfo information to
13 grow the stack. If we don't get the siginfo, then it just looks
14 like the program crashed.
16 The extra complication in this test is making sure that the
17 unwanted signals are discarded while the main thread is blocked in
18 a syscall. So, to check this, main creates a new process, which
19 attempts to grow the stack once all the threads have been created
20 and exited. main() itself is blocked waiting for the child
23 Oh, and this test also makes sure that thread resources are cleaned
36 static void handler(int sig
)
40 static void *thr(void *v
)
47 static void grow(int depth
)
49 volatile char frame
[FRAME
];
51 memset((char *)frame
, 0xff, sizeof(frame
));
57 static void *maker(void *v
)
63 /* Create lots of threads */
64 printf("creating threads...\n");
65 for(i
= 0; i
< 1300; i
++) {
72 ret
= pthread_create(&t
, NULL
, thr
, NULL
);
74 printf("pthread_create failed: %s\n", strerror(ret
));
78 ret
= pthread_join(t
, NULL
);
80 printf("pthread_join failed: %s\n", strerror(ret
));
85 kill(grower
, SIGUSR1
);
98 sigaddset(&mask
, SIGCHLD
);
99 sigprocmask(SIG_BLOCK
, &mask
, NULL
);
101 sa
.sa_handler
= handler
;
103 sigfillset(&sa
.sa_mask
);
104 sigaction(SIGUSR1
, &sa
, NULL
);
114 pause(); /* child - wait for SIGUSR1 */
116 printf("stack grew OK\n");
120 pthread_create(&pth
, NULL
, maker
, NULL
);
123 if (waitpid(grower
, &status
, 0) != grower
)
125 else if (WIFEXITED(status
) && WEXITSTATUS(status
) == 0)
126 printf("PASS: child OK\n");
128 printf("FAILED: exit status=%d\n", status
);
130 pthread_join(pth
, NULL
);