1 /* $NetBSD: sigalrm.c,v 1.4 2006/05/10 19:07:22 mrg Exp $ */
4 #include <sys/ucontext.h>
12 sigalrm(int signo
, siginfo_t
*info
, void *ptr
)
15 printf("%d %p %p\n", signo
, info
, ptr
);
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
);
23 ucontext_t
*ctx
= ptr
;
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
,
40 assert(info
->si_signo
== SIGALRM
);
41 assert(info
->si_code
== SI_TIMER
);
42 assert(info
->si_value
.sival_int
== ITIMER_REAL
);
50 sa
.sa_flags
= SA_SIGINFO
;
51 sa
.sa_sigaction
= sigalrm
;
52 sigemptyset(&sa
.sa_mask
);
53 sigaction(SIGALRM
, &sa
, NULL
);