sigsetjmp_test.c revision 68855535
1/*
2 * Copyright 2005, Axel D��rfler, axeld@pinc-software.de.
3 * Distributed under the terms of the MIT License.
4 */
5
6
7#include <stdio.h>
8#include <setjmp.h>
9
10void
11jump_to_top_level(jmp_buf *state, int value)
12{
13	siglongjmp(*state, value);
14}
15
16
17int
18main(int argc, char **argv)
19{
20	jmp_buf state;
21	int value;
22
23	if (value = sigsetjmp(state, 1)) {
24		printf("failed with: %d!\n", value);
25	} else {
26		printf("here I am: %d\n", value);
27		jump_to_top_level(&state, 42);
28		printf("you won't see me!\n");
29	}
30
31	puts("done.");
32	return 0;
33}
34