};
static ARRAY(struct atexit_callback) atexit_callbacks = ARRAY_INIT;
+static bool lib_registered_atexit = FALSE;
static bool lib_clean_exit;
/* The original faccessat() syscall didn't handle the flags parameter. glibc
static void lib_atexit_handler(void)
{
+ if (!lib_initialized)
+ return;
+
/* We're already in exit code path. Avoid using any functions that
might cause strange breakage. Especially anything that could call
exit() again could cause infinite looping in some OSes. */
of using lib_exit(). master_service_init_finish() will change this
again to be FALSE. */
lib_set_clean_exit(TRUE);
- atexit(lib_atexit_handler);
+ if (!lib_registered_atexit) {
+ atexit(lib_atexit_handler);
+ lib_registered_atexit = TRUE;
+ }
lib_initialized = TRUE;
}