* sysdeps/m68k/setjmp.c: Also define setjmp and _setjmp if
[glibc.git] / manual / examples / setjmp.c
blob023339c6021702d481c6de8d448d4f7497257461
1 #include <setjmp.h>
2 #include <stdlib.h>
3 #include <stdio.h>
5 jmp_buf main_loop;
7 void
8 abort_to_main_loop (int status)
10 longjmp (main_loop, status);
13 int
14 main (void)
16 while (1)
17 if (setjmp (main_loop))
18 puts ("Back at main loop....");
19 else
20 do_command ();
24 void
25 do_command (void)
27 char buffer[128];
28 if (fgets (buffer, 128, stdin) == NULL)
29 abort_to_main_loop (-1);
30 else
31 exit (EXIT_SUCCESS);