Warning: That file was not part of the compilation database. It may have many parsing errors.

1/* Copyright (C) 2003-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#include <errno.h>
20#include <pthread.h>
21#include <signal.h>
22#include <stdio.h>
23#include <stdlib.h>
24#include <string.h>
25
26static int do_test (void);
27
28#define TEST_FUNCTION do_test ()
29#include "../test-skeleton.c"
30
31#include "eintr.c"
32
33
34static void *
35tf2 (void *arg)
36{
37 return arg;
38}
39
40
41static void *
42tf1 (void *arg)
43{
44 while (1)
45 {
46 pthread_t th;
47
48 int e = pthread_create (&th, NULL, tf2, NULL);
49 if (e != 0)
50 {
51 if (e == EINTR)
52 {
53 puts ("pthread_create returned EINTR");
54 exit (1);
55 }
56
57 char buf[100];
58 printf ("tf1: pthread_create failed: %s\n",
59 strerror_r (e, buf, sizeof (buf)));
60 exit (1);
61 }
62
63 e = pthread_join (th, NULL);
64 if (e != 0)
65 {
66 if (e == EINTR)
67 {
68 puts ("pthread_join returned EINTR");
69 exit (1);
70 }
71
72 char buf[100];
73 printf ("tf1: pthread_join failed: %s\n",
74 strerror_r (e, buf, sizeof (buf)));
75 exit (1);
76 }
77 }
78}
79
80
81static int
82do_test (void)
83{
84 setup_eintr (SIGUSR1, NULL);
85
86 int i;
87 for (i = 0; i < 10; ++i)
88 {
89 pthread_t th;
90 int e = pthread_create (&th, NULL, tf1, NULL);
91 if (e != 0)
92 {
93 char buf[100];
94 printf ("main: pthread_create failed: %s\n",
95 strerror_r (e, buf, sizeof (buf)));
96 exit (1);
97 }
98 }
99
100 delayed_exit (3);
101 /* This call must never return. */
102 (void) tf1 (NULL);
103 return 1;
104}
105

Warning: That file was not part of the compilation database. It may have many parsing errors.