1 /* This is a test of the special shutdown that occurs
2 when all threads, including the main one, call
3 pthread_exit(). It demonstrates that atexit
4 handlers are properly called, and that the
5 output is properly flushed even when stdout is
6 redirected to a file, and therefore fully buffered. */
12 #define NTHREADS 20 /* number of threads */
17 printf ("thread terminating\n");
24 printf ("atexit handler called\n");
34 for (i
= 0; i
< NTHREADS
; i
++)
37 if (pthread_create (&id
, 0, thread
, 0) != 0)
39 fprintf (stderr
, "pthread_create failed\n");