No empty .Rs/.Re
[netbsd-mini2440.git] / regress / lib / libc / siginfo / sigalrm / sigalrm.c
blob773356764ec3f80dcd2c36de0d6792e4cc5e5477
1 /* $NetBSD: sigalrm.c,v 1.4 2006/05/10 19:07:22 mrg Exp $ */
3 #include <sys/time.h>
4 #include <sys/ucontext.h>
6 #include <assert.h>
7 #include <signal.h>
8 #include <stdio.h>
9 #include <stdlib.h>
11 void
12 sigalrm(int signo, siginfo_t *info, void *ptr)
14 #ifdef DEBUG
15 printf("%d %p %p\n", signo, info, ptr);
16 if (info != NULL) {
17 printf("si_signo=%d\n", info->si_signo);
18 printf("si_errno=%d\n", info->si_errno);
19 printf("si_code=%d\n", info->si_code);
20 printf("si_value.sival_int=%d\n", info->si_value.sival_int);
22 if (ptr != NULL) {
23 ucontext_t *ctx = ptr;
24 int i;
25 mcontext_t *mc = &ctx->uc_mcontext;
26 printf("uc_flags 0x%x\n", ctx->uc_flags);
27 printf("uc_link %p\n", ctx->uc_link);
28 for (i = 0; i < sizeof(ctx->uc_sigmask.__bits) /
29 sizeof(ctx->uc_sigmask.__bits[0]); i++)
30 printf("uc_sigmask[%d] 0x%x\n", i,
31 ctx->uc_sigmask.__bits[i]);
32 printf("uc_stack %p %lu 0x%x\n", ctx->uc_stack.ss_sp,
33 (unsigned long)ctx->uc_stack.ss_size,
34 ctx->uc_stack.ss_flags);
35 for (i = 0; i < sizeof(mc->__gregs)/sizeof(mc->__gregs[0]); i++)
36 printf("uc_mcontext.greg[%d] 0x%x\n", i,
37 mc->__gregs[i]);
39 #endif
40 assert(info->si_signo == SIGALRM);
41 assert(info->si_code == SI_TIMER);
42 assert(info->si_value.sival_int == ITIMER_REAL);
43 exit(0);
46 int
47 main(void)
49 struct sigaction sa;
50 sa.sa_flags = SA_SIGINFO;
51 sa.sa_sigaction = sigalrm;
52 sigemptyset(&sa.sa_mask);
53 sigaction(SIGALRM, &sa, NULL);
54 for (;;) {
55 alarm(1);
56 sleep(1);
58 return 0;