#endif /* USE_CFBUNDLE */
#ifdef RTLD_GROUP
-#define PLUGIN_DLOPEN_FLAGS (RTLD_NOW | RTLD_LOCAL | RTLD_GROUP)
+# ifdef RTLD_NODELETE
+# define PLUGIN_DLOPEN_FLAGS (RTLD_NOW | RTLD_LOCAL | RTLD_GROUP | RTLD_NODELETE)
+# else
+# define PLUGIN_DLOPEN_FLAGS (RTLD_NOW | RTLD_LOCAL | RTLD_GROUP)
+# endif
#else
-#define PLUGIN_DLOPEN_FLAGS (RTLD_NOW | RTLD_LOCAL)
+# ifdef RTLD_NODELETE
+# define PLUGIN_DLOPEN_FLAGS (RTLD_NOW | RTLD_LOCAL | RTLD_NODELETE)
+# else
+# define PLUGIN_DLOPEN_FLAGS (RTLD_NOW | RTLD_LOCAL)
+# endif
#endif
if (!err) {
- handle = dlopen(filepath, PLUGIN_DLOPEN_FLAGS | RTLD_NODELETE);
+ handle = dlopen(filepath, PLUGIN_DLOPEN_FLAGS);
if (handle == NULL) {
const char *e = dlerror();
if (e == NULL)