aboutsummaryrefslogtreecommitdiffstats
path: root/tests/signal-interrupt.c
blob: 7b6988fdf63f90fe8a2ef3359befada79775dfdc (plain) (blame)
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
#include <signal.h>
#include <time.h>
#include <unistd.h>

static void
interrupt()
{
	write(-2, "xyzzy\n", 6);
}

int
main(void)
{
	struct timespec ts = {0, 100000000L};
	pid_t pid = getpid();
	signal(SIGINT, interrupt);
	if (fork() == 0) {
		ts.tv_nsec /= 2;
		nanosleep(&ts, NULL);
		kill(pid, SIGINT);
	} else {
		nanosleep(&ts, NULL);
		write(-1, "qwerty\n", 7);
	}
	return 0;
}