diff --git a/headers/private/system/user_runtime.h b/headers/private/system/user_runtime.h index 08dea23176..e06229b538 100644 --- a/headers/private/system/user_runtime.h +++ b/headers/private/system/user_runtime.h @@ -46,6 +46,8 @@ struct rld_export { void (*call_atexit_hooks_for_range)(addr_t start, addr_t size); + void (*call_termination_hooks)(); + const struct user_space_program_args *program_args; }; diff --git a/src/system/libroot/posix/stdlib/exit.c b/src/system/libroot/posix/stdlib/exit.c index ee13b0fb95..b9920d9d91 100644 --- a/src/system/libroot/posix/stdlib/exit.c +++ b/src/system/libroot/posix/stdlib/exit.c @@ -8,12 +8,15 @@ */ -#include +#include + +#include #include #include #include -#include -#include + +#include +#include extern void _IO_cleanup(void); @@ -144,6 +147,8 @@ exit(int status) // close all open files _IO_cleanup(); + __gRuntimeLoader->call_termination_hooks(); + // exit with status code _kern_exit_team(status); } diff --git a/src/system/runtime_loader/export.c b/src/system/runtime_loader/export.c index 795a0aea9d..03c3d73f8c 100644 --- a/src/system/runtime_loader/export.c +++ b/src/system/runtime_loader/export.c @@ -37,7 +37,8 @@ struct rld_export gRuntimeLoader = { get_next_image_dependency, elf_reinit_after_fork, - NULL // call_atexit_hooks_for_range + NULL, // call_atexit_hooks_for_range + terminate_program };