libc.obj: add atexit and normal exit. add exit code save/read
This commit is contained in:
29
programs/develop/ktcc/trunk/libc.obj/source/stdlib/_exit.c
Normal file
29
programs/develop/ktcc/trunk/libc.obj/source/stdlib/_exit.c
Normal file
@@ -0,0 +1,29 @@
|
||||
#include <conio.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/ksys.h>
|
||||
#include "_exit.h"
|
||||
|
||||
void _exit(int status)
|
||||
{
|
||||
__libc_exit(status, NULL);
|
||||
}
|
||||
|
||||
void __libc_exit(int status, void (*before_exit)(int status))
|
||||
{
|
||||
// return error and this is not abort
|
||||
if (status && status != 128) {
|
||||
fprintf(stderr, "\nexit code: %d\n", status);
|
||||
}
|
||||
|
||||
WRITE_EXIT_CODE(status);
|
||||
|
||||
if (before_exit) {
|
||||
before_exit(status);
|
||||
}
|
||||
|
||||
if (__con_is_load) {
|
||||
con_exit(0);
|
||||
}
|
||||
|
||||
_ksys_exit();
|
||||
}
|
||||
Reference in New Issue
Block a user