/[baselayout]/trunk/src/rc-plugin.c
Gentoo

Diff of /trunk/src/rc-plugin.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 3048 Revision 3049
3 Simple plugin handler 3 Simple plugin handler
4 Copyright 2007 Gentoo Foundation 4 Copyright 2007 Gentoo Foundation
5 Released under the GPLv2 5 Released under the GPLv2
6 */ 6 */
7 7
8#include <sys/types.h>
9#include <sys/wait.h>
8#include <dirent.h> 10#include <dirent.h>
9#include <dlfcn.h> 11#include <dlfcn.h>
10#include <errno.h> 12#include <errno.h>
11#include <fcntl.h> 13#include <fcntl.h>
12#include <limits.h> 14#include <limits.h>
95 plugin->handle = h; 97 plugin->handle = h;
96 plugin->hook = fptr; 98 plugin->hook = fptr;
97 } 99 }
98 } 100 }
99 closedir (dp); 101 closedir (dp);
102}
103
104int rc_waitpid (pid_t pid)
105{
106 int status = 0;
107 pid_t savedpid = pid;
108 int retval = -1;
109
110 errno = 0;
111 while ((pid = waitpid (savedpid, &status, 0)) > 0) {
112 if (pid == savedpid)
113 retval = WIFEXITED (status) ? WEXITSTATUS (status) : EXIT_FAILURE;
114 }
115
116 return (retval);
100} 117}
101 118
102void rc_plugin_run (rc_hook_t hook, const char *value) 119void rc_plugin_run (rc_hook_t hook, const char *value)
103{ 120{
104 plugin_t *plugin = plugins; 121 plugin_t *plugin = plugins;
174 } 191 }
175 } 192 }
176 193
177 free (buffer); 194 free (buffer);
178 close (pfd[0]); 195 close (pfd[0]);
196
197 rc_waitpid (pid);
179 } 198 }
180 } 199 }
181 plugin = plugin->next; 200 plugin = plugin->next;
182 } 201 }
183} 202}

Legend:
Removed from v.3048  
changed lines
  Added in v.3049

  ViewVC Help
Powered by ViewVC 1.1.20