source: vendor/glibc-tests/glibc/nptl/tst-exit3.c

Last change on this file was 2036, checked in by bird, 20 years ago

Initial revision

  • Property cvs2svn:cvs-rev set to 1.1
  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 1.3 KB
Line 
1#include <pthread.h>
2#include <signal.h>
3#include <stdio.h>
4#include <stdlib.h>
5#include <string.h>
6#include <unistd.h>
7
8
9static pthread_barrier_t b;
10
11
12static void *
13tf2 (void *arg)
14{
15 while (1)
16 sleep (100);
17
18 /* NOTREACHED */
19 return NULL;
20}
21
22
23static void *
24tf (void *arg)
25{
26 pthread_t th;
27
28 int e = pthread_barrier_wait (&b);
29 if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
30 {
31 puts ("barrier_wait failed");
32 exit (1);
33 }
34
35 e = pthread_create (&th, NULL, tf2, NULL);
36 if (e != 0)
37 {
38 printf ("create failed: %s\n", strerror (e));
39 exit (1);
40 }
41
42 /* Terminate only this thread. */
43 return NULL;
44}
45
46
47static int
48do_test (void)
49{
50 pthread_t th;
51
52 if (pthread_barrier_init (&b, NULL, 2) != 0)
53 {
54 puts ("barrier_init failed");
55 exit (1);
56 }
57
58 int e = pthread_create (&th, NULL, tf, NULL);
59 if (e != 0)
60 {
61 printf ("create failed: %s\n", strerror (e));
62 exit (1);
63 }
64
65 e = pthread_barrier_wait (&b);
66 if (e != 0 && e != PTHREAD_BARRIER_SERIAL_THREAD)
67 {
68 puts ("barrier_wait failed");
69 exit (1);
70 }
71
72 /* Terminate only this thread. */
73 pthread_exit (NULL);
74
75 /* NOTREACHED */
76 return 1;
77}
78
79#define EXPECTED_SIGNAL SIGALRM
80#define TEST_FUNCTION do_test ()
81#include "../test-skeleton.c"
Note: See TracBrowser for help on using the repository browser.