on_exit(...) function

Could somebody tell me how to replace a missing function on_exit? It's a little bit non-standard, available under Linux, but very useful. I need to pass args that atexit cannot. 🧐
 
I don't know if this is possible. As a suggestion maybe to use atexit() with the combination of global variable that will serve the purpose of the argument.
 
This function comes from SunOS 4, but is also present in glibc. It
no longer occurs in Solaris (SunOS 5). Portable application should
avoid this function, and use the standard atexit(3) instead.
From the on_exit(3) man page.
 
True. But that isn't really clear from the original question. It might be an application jsika wrote himself.
 
As _martin said, I resolved it with atexit() and a global value. It was for a web server, to detect termination of fork/eval process.
I've even found __cxa_atexit function from sources, which is similar, but it didn't work for me at all.
 
As _martin said, I resolved it with atexit() and a global value. It was for a web server, to detect termination of fork/eval process.
I've even found __cxa_atexit function from sources, which is similar, but it didn't work for me at all.
Glad you got things working. :)

Just so you and future readers are aware, __cxa_atexit isn't meant to be called directly by application-level code. See https://wiki.openoffice.org/wiki/GCC_cxa_atexit and GCC - C++ Dialect Options: -fuse-cxa-atexit for more GCC-specific information; the clang implementation is presumably compatible, but I cannot guarantee that with a reasonable amount of certainty. Things may differ in the case of GCC compiled for the ARM EABI (GCC Internals: Target Hook bool TARGET_CXX_USE_AEABI_ATEXIT (void)).

Edit: The OSDev wiki has a bit of info on it as well, so it's highly likely to be some low-level stuff for compiler implementations rather than something you'd call yourself in an application.
 
Back
Top