blob: 386a1bf9fed950bcf253179979b2d14ddd4d8b1e (
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
27
28
29
30
31
32
33
34
|
#include <u.h>
#include <rt.h>
#include <syscall.h>
/* tell linker to go find */
void noreturn exit(int code);
/* if did not call rt·atexit, then don't pull it in */
static void noop(void){}
weakalias(noop, rt·clean);
static noreturn void
rt·shutdown(int code)
{
if(rt·context.fini)
rt·context.fini();
if(rt·context.exit)
rt·context.exit();
/* XXX: better way to encapsulate these calls? */
_syscall1(·ExitGroup, code);
for(;;)
_syscall1(·Exit, code);
}
noreturn void
rt·exit(int code)
{
/* ring libc, anyone home? */
exit(code);
/* if we are here, we are in charge, shut it down */
rt·clean();
rt·shutdown(code);
}
|