Don't use .Xo/.Xc. Fix date format.
[netbsd-mini2440.git] / regress / lib / libpthread / sleep1 / sleep1.c
blob48babee7aebb2b41ba79b576a6efac8942567d04
1 /* $NetBSD: sleep1.c,v 1.2 2005/08/29 18:52:16 drochner Exp $ */
3 #include <signal.h>
4 #include <stdio.h>
5 #include <pthread.h>
6 #include <unistd.h>
8 #include <sys/time.h>
10 void *threadfunc(void *);
11 void handler(int);
13 #define LONGTIME 2000000000
15 int
16 main(void)
18 pthread_t thread;
19 struct itimerval it;
20 struct sigaction act;
21 sigset_t mtsm;
23 printf("Testing sleeps unreasonably far into the future.\n");
25 act.sa_handler = handler;
26 sigemptyset(&act.sa_mask);
27 act.sa_flags = 0;
28 sigaction(SIGALRM, &act, NULL);
30 pthread_create(&thread, NULL, threadfunc, NULL);
32 /* make sure the signal is delivered to the child thread */
33 sigemptyset(&mtsm);
34 sigaddset(&mtsm, SIGALRM);
35 pthread_sigmask(SIG_BLOCK, &mtsm, 0);
37 timerclear(&it.it_interval);
38 timerclear(&it.it_value);
39 it.it_value.tv_sec = 1;
40 setitimer(ITIMER_REAL, &it, NULL);
42 pthread_join(thread, NULL);
44 printf("Passed.\n");
46 return 0;
49 void *
50 threadfunc(void *arg)
52 sleep(LONGTIME);
53 return NULL;
56 void
57 handler(int sig)
60 * Nothing to do; invoking the handler is enough to interrupt
61 * the sleep.