Inside my registered atexit () function, I would like to get the exit status (either the argument exit (3) or the return main ()).
Is there any portable way to do this? Is there any GNU libc specific way to do this, such as a global holding whose value I can reference?
Here is the hack:
// hack.c int last_exit; // hack.h extern int last_exit; #define exit(x) (exit)(last_exit = (x))
Doesn't work for return, but, hey, it carries over!
return
- , - . , GCC exit(), . , , , , , . return, return . .
exit()
on_exit. , Posix, , , glibc.
on_exit