summaryrefslogtreecommitdiff
path: root/regress/lib/libc/setjmp-signal/setjmp-signal.c
blob: 310e4052effee573ac71de8d4e3a451e377fbd18 (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
/*	$OpenBSD: setjmp-signal.c,v 1.3 2003/01/03 20:46:05 miod Exp $	*/
/*
 *	Written by Artur Grabowski <art@openbsd.org> 2002 Public Domain.
 */

#include <setjmp.h>
#include <signal.h>

jmp_buf jb;

void
segv_handler(int signum)
{
	longjmp(jb, 1);
}

int
main()
{
	signal(SIGSEGV, segv_handler);
	if (setjmp(jb) == 0) {
		*((int *)0L) = 0;
		return (1);
	}
	return (0);
}