repo.or.cz
/
glibc
/
nacl-glibc.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
Override elf_nacl.xr linker script so that libc_pic.os links correctly
[glibc/nacl-glibc.git]
/
manual
/
examples
/
setjmp.c
blob
023339c6021702d481c6de8d448d4f7497257461
1
#include <setjmp.h>
2
#include <stdlib.h>
3
#include <stdio.h>
4
5
jmp_buf
main_loop
;
6
7
void
8
abort_to_main_loop
(
int
status
)
9
{
10
longjmp
(
main_loop
,
status
);
11
}
12
13
int
14
main
(
void
)
15
{
16
while
(
1
)
17
if
(
setjmp
(
main_loop
))
18
puts
(
"Back at main loop...."
);
19
else
20
do_command
();
21
}
22
23
24
void
25
do_command
(
void
)
26
{
27
char
buffer
[
128
];
28
if
(
fgets
(
buffer
,
128
,
stdin
) ==
NULL
)
29
abort_to_main_loop
(-
1
);
30
else
31
exit
(
EXIT_SUCCESS
);
32
}