diff options
Diffstat (limited to 'sys/rt/exit.c')
-rw-r--r-- | sys/rt/exit.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/sys/rt/exit.c b/sys/rt/exit.c index e6027b7..386a1bf 100644 --- a/sys/rt/exit.c +++ b/sys/rt/exit.c @@ -2,10 +2,13 @@ #include <rt.h> #include <syscall.h> -/* XXX: - * if we are here, we are in charge, call exit syscalls - * think of better way to encapsulate these syscalls? - */ +/* 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) { @@ -14,14 +17,18 @@ rt·shutdown(int code) if(rt·context.exit) rt·context.exit(); + /* XXX: better way to encapsulate these calls? */ _syscall1(·ExitGroup, code); for(;;) _syscall1(·Exit, code); } -weakalias(rt·shutdown, exit); noreturn void rt·exit(int code) { - rt·shutdown(code); + /* ring libc, anyone home? */ + exit(code); + /* if we are here, we are in charge, shut it down */ + rt·clean(); + rt·shutdown(code); } |