libc.obj: add atexit and normal exit. add exit code save/read
All checks were successful
Build system / Check kernel codestyle (pull_request) Successful in 20s
Build system / Build (pull_request) Successful in 16m18s

This commit is contained in:
2026-02-22 13:56:25 +05:00
parent 0319a2d7cb
commit ba8747e2ab
6 changed files with 159 additions and 5 deletions

View 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();
}