diff -ur collectd-5.2.0.orig/src/exec.c collectd-5.2.0/src/exec.c
--- collectd-5.2.0.orig/src/exec.c	2012-11-17 14:23:21.000000000 -0800
+++ collectd-5.2.0/src/exec.c	2013-02-21 13:45:27.184324211 -0800
@@ -398,7 +398,8 @@
     exit (-1);
   }
 
-  status = execvp (pl->exec, pl->argv);
+  close_dlhandles_call_execvp (pl->exec, pl->argv);
+  /* The above should never return. */
 
   ERROR ("exec plugin: Failed to execute ``%s'': %s",
       pl->exec, sstrerror (errno, errbuf, sizeof (errbuf)));
diff -ur collectd-5.2.0.orig/src/plugin.c collectd-5.2.0/src/plugin.c
--- collectd-5.2.0.orig/src/plugin.c	2012-11-17 14:23:21.000000000 -0800
+++ collectd-5.2.0/src/plugin.c	2013-02-21 14:02:48.741350845 -0800
@@ -68,6 +68,12 @@
 	struct timespec rf_next_read;
 };
 typedef struct read_func_s read_func_t;
+struct dlhandle_elem_s
+{
+        lt_dlhandle             dlh;
+        struct dlhandle_elem_s *next;
+};
+typedef struct dlhandle_elem_s dlhandle_elem_t;
 
 /*
  * Private variables
@@ -98,6 +104,9 @@
 static pthread_key_t   plugin_ctx_key;
 static _Bool           plugin_ctx_key_initialized = 0;
 
+static pthread_mutex_t  dlhandle_lock = PTHREAD_MUTEX_INITIALIZER;
+static dlhandle_elem_t *dlhandle_list = NULL;
+
 /*
  * Static functions
  */
@@ -277,6 +286,25 @@
 	return (0);
 } /* }}} int plugin_unregister */
 
+/* Remember a dl handle for possible later closing. */
+/* Return zero for success, an error code for error. */
+static int remember_dlhandle (lt_dlhandle dlh)
+{
+        dlhandle_elem_t *elem;
+        pthread_mutex_lock (&dlhandle_lock);
+        elem = malloc (sizeof(dlhandle_elem_t));
+        if (elem == NULL)
+        {
+		ERROR ("remember_dlhandle: malloc failed.");
+		return (ENOMEM);
+        }
+        elem->dlh = dlh;
+        elem->next = dlhandle_list;
+        dlhandle_list = elem;
+        pthread_mutex_unlock (&dlhandle_lock);
+        return (0);
+} /* void remember_plugin */
+
 /*
  * (Try to) load the shared object `file'. Won't complain if it isn't a shared
  * object, but it will bitch about a shared object not having a
@@ -286,6 +314,7 @@
 {
 	lt_dlhandle dlh;
 	void (*reg_handle) (void);
+        int stat;
 
 	lt_dlinit ();
 	lt_dlerror (); /* clear errors */
@@ -336,6 +365,12 @@
 		return (-1);
 	}
 
+        stat = remember_dlhandle (dlh);
+        if (0 != stat)
+        {
+                return (stat);
+        }
+
 	(*reg_handle) ();
 
 	return (0);
@@ -576,6 +611,36 @@
 /*
  * Public functions
  */
+void close_dlhandles_call_execvp(const char *file, char *const argv[])
+{
+
+        /* This function is intended _only_ for closing dl handles after   */
+        /* calling fork() in a child process.  It closes the dymically     */
+        /* loaded module but does not unregister the plugin.               */
+
+        char errbuf[1024];
+
+        while (NULL != dlhandle_list)
+        {
+            dlhandle_elem_t *elem;
+            pthread_mutex_lock (&dlhandle_lock);
+            elem = dlhandle_list;
+            dlhandle_list = elem->next;
+            pthread_mutex_unlock (&dlhandle_lock);
+            lt_dlclose(elem->dlh);
+            free(elem);
+        }
+
+        /* Call execvp() from here, because the exec plugin module has */
+        /* been unloaded. */
+        execvp (file, argv);
+
+        ERROR ("close_dlhandles_call_execvp: Failed to execute ``%s'': %s",
+            file, sstrerror (errno, errbuf, sizeof (errbuf)));
+        exit (-1);
+
+} /* void close_dlhandles_call_execvp */
+
 void plugin_set_dir (const char *dir)
 {
 	if (plugindir != NULL)
diff -ur collectd-5.2.0.orig/src/plugin.h collectd-5.2.0/src/plugin.h
--- collectd-5.2.0.orig/src/plugin.h	2012-11-17 14:23:21.000000000 -0800
+++ collectd-5.2.0/src/plugin.h	2013-02-21 12:24:26.682194373 -0800
@@ -191,6 +191,21 @@
 
 /*
  * NAME
+ *  close_dlhandles_call_execvp
+ *
+ * DESCRIPTION
+ *  Closes dynamically loaded modules.
+ *
+ * ARGUMENTS
+ *  none
+ *
+ * NOTES
+ *  Only call this after fork() and FD housekeeping in a child process.
+ */
+void close_dlhandles_call_execvp (const char *file, char *const argv[]);
+
+/*
+ * NAME
  *  plugin_set_dir
  *
  * DESCRIPTION
