문제

For functions registered using atexit(): Is it possible to retrieve references to them, to call them directly?

Although this is meant as a general question, solutions regarding the use of gcc/glibc are welcome.

도움이 되었습니까?

해결책

Not in any portable way, no. The list of registered functions is owned by the runtime library, and there is no interface to access it.

For glibc specifics as per your comment, the exit handlers are implemented by exit.c and exit.h. I haven't studied them intensely enough to figure out of it's possible to drill through the abstraction/data hiding. You might need to e.g. include glibc-specific headers that probably aren't generally available, for instance.

다른 팁

No. However, if you have control over all the code in the application, you could maintain a list yourself, and register a single function to the real atexit() which would run through the list when the system is terminated.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top