static int do_test (void) { pthread_t self = pthread_self (); setup_eintr (SIGUSR1, &self); pthread_t th; char buf[100]; int e = pthread_create (&th, NULL, tf, NULL); if (e != 0) { printf ("main: pthread_create failed: %s\n", strerror_r (e, buf, sizeof (buf))); exit (1); } /* This call must never return. */ e = pthread_join (th, NULL); if (e == EINTR) puts ("pthread_join returned with EINTR"); return 0; }
static void * tf2 (void *arg) { while (1) { int e = pthread_mutex_lock (&m2); if (e != 0) { puts ("tf2: mutex_lock failed"); exit (1); } e = pthread_mutex_unlock (&m2); if (e != 0) { puts ("tf2: mutex_unlock failed"); exit (1); } struct timespec ts = { .tv_sec = 0, .tv_nsec = 10000000 }; nanosleep (&ts, NULL); } } static int do_test (void) { if (pthread_mutex_lock (&m1) != 0) { puts ("mutex_lock failed"); exit (1); } setup_eintr (SIGUSR1, NULL); pthread_t th; char buf[100]; int e = pthread_create (&th, NULL, tf1, NULL); if (e != 0) { printf ("main: 1st pthread_create failed: %s\n", strerror_r (e, buf, sizeof (buf))); exit (1); } e = pthread_create (&th, NULL, tf2, NULL); if (e != 0) { printf ("main: 2nd pthread_create failed: %s\n", strerror_r (e, buf, sizeof (buf))); exit (1); } /* This call must never return. */ e = pthread_mutex_lock (&m1); printf ("main: mutex_lock returned: %s\n", strerror_r (e, buf, sizeof (buf))); return 0; }
static int do_test (void) { setup_eintr (SIGUSR1, NULL); pthread_t th; char buf[100]; int e = pthread_create (&th, NULL, tf, NULL); if (e != 0) { printf ("main: pthread_create failed: %s\n", strerror_r (e, buf, sizeof (buf))); exit (1); } /* This call must never return. */ e = pthread_cond_wait (&c, &m); printf ("main: cond_wait returned: %s\n", strerror_r (e, buf, sizeof (buf))); return 0; }
static int do_test (void) { pthread_t self = pthread_self (); setup_eintr (SIGUSR1, &self); pthread_barrier_t b; if (pthread_barrier_init (&b, NULL, 2) != 0) { puts ("barrier_init failed"); exit (1); } /* This call must never return. */ int e = pthread_barrier_wait (&b); if (e == EINTR) puts ("pthread_join returned with EINTR"); return 0; }
static int do_test (void) { setup_eintr (SIGUSR1, NULL); int i; for (i = 0; i < 10; ++i) { pthread_t th; int e = pthread_create (&th, NULL, tf1, NULL); if (e != 0) { char buf[100]; printf ("main: pthread_create failed: %s\n", strerror_r (e, buf, sizeof (buf))); exit (1); } } delayed_exit (3); /* This call must never return. */ (void) tf1 (NULL); return 1; }
static int do_test (void) { setup_eintr (SIGUSR1, NULL); int i; for (i = 0; i < 10; ++i) { pthread_t th; int e = pthread_create (&th, NULL, tf1, NULL); if (e != 0) { char buf[100]; printf ("main: pthread_create failed: %s\n", strerror_r (e, buf, sizeof (buf))); exit (1); } } (void) tf1 (NULL); /* NOTREACHED */ return 0; }