1 /* reset.c 4.2 90/06/23 */ 2 3 /* 4 * This can't be written in C. You have to longjmp from a context 5 * below (stackwise) the call to setjmp: 6 * 7 * /* test reset/setexit *(/ 8 * main() 9 * { 10 * int i = setexit(); 11 * printf("i=%d\n", i); 12 * if (i == 0) 13 * reset(1); 14 * } 15 * 16 * The above prints `longjmp botch' and dumps core. 17 */ 18 19 /* 20 * Backwards compatible setexit/reset. 21 */ 22 #include <setjmp.h> 23 24 static jmp_buf save; 25 26 setexit() 27 { 28 29 return (setjmp(save)); 30 } 31 32 reset(x) 33 { 34 35 longjmp(save, x); 36 } 37