blob: 2661d4aff89150d5c020742371baf8a212c38088 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
/* $OpenBSD: test_signal.c,v 1.1 2000/01/04 00:17:46 d Exp $ */
/*
* This program tests signal handler re-entrancy.
*/
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <signal.h>
#include "test.h"
void *
sleeper(arg)
void *arg;
{
sigset_t mask;
/* Ignore all signals in this thread */
sigfillset(&mask);
CHECKe(sigprocmask(SIG_SETMASK, &mask, NULL));
ASSERT(sleep(10) == 0);
SUCCEED;
}
void
handler(sig)
int sig;
{
printf("signal handler %d\n", sig);
alarm(1);
signal(SIGALRM, handler);
}
int
main()
{
pthread_t slpr;
ASSERT(signal(SIGALRM, handler) != SIG_ERR);
CHECKe(alarm(1));
/* CHECKr(pthread_create(&slpr, NULL, sleeper, NULL)); */
/* ASSERT(sleep(1) == 0); */
for (;;)
CHECKe(write(STDOUT_FILENO, ".", 1));
}
|