aboutsummaryrefslogtreecommitdiff
path: root/src/rc-plugin.c
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2007-10-22 19:33:42 +0000
committerRoy Marples <roy@marples.name>2007-10-22 19:33:42 +0000
commit9dddb43eb49d07d8c1b87e11c8d259fd41a34ae4 (patch)
treebb4d9e3908468f9a4347c19842afd7da62850525 /src/rc-plugin.c
parent6b0c28039d051af85f009cb2cbc4c77a3d93bdb0 (diff)
Wait for plugins to finish before moving on.
Diffstat (limited to 'src/rc-plugin.c')
-rw-r--r--src/rc-plugin.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/rc-plugin.c b/src/rc-plugin.c
index 1cdf5690..605ced68 100644
--- a/src/rc-plugin.c
+++ b/src/rc-plugin.c
@@ -5,6 +5,8 @@
Released under the GPLv2
*/
+#include <sys/types.h>
+#include <sys/wait.h>
#include <dirent.h>
#include <dlfcn.h>
#include <errno.h>
@@ -99,6 +101,21 @@ void rc_plugin_load (void)
closedir (dp);
}
+int rc_waitpid (pid_t pid)
+{
+ int status = 0;
+ pid_t savedpid = pid;
+ int retval = -1;
+
+ errno = 0;
+ while ((pid = waitpid (savedpid, &status, 0)) > 0) {
+ if (pid == savedpid)
+ retval = WIFEXITED (status) ? WEXITSTATUS (status) : EXIT_FAILURE;
+ }
+
+ return (retval);
+}
+
void rc_plugin_run (rc_hook_t hook, const char *value)
{
plugin_t *plugin = plugins;
@@ -176,6 +193,8 @@ void rc_plugin_run (rc_hook_t hook, const char *value)
free (buffer);
close (pfd[0]);
+
+ rc_waitpid (pid);
}
}
plugin = plugin->next;