projects
/
collectd.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
6dee31b
)
exec plugin: Send SIGTERM to all running child-processes when exiting.
author
Florian Forster
<octo@leeloo.lan.home.verplant.org>
Fri, 30 Mar 2007 19:45:38 +0000
(21:45 +0200)
committer
Florian Forster
<octo@leeloo.lan.home.verplant.org>
Fri, 30 Mar 2007 19:45:38 +0000
(21:45 +0200)
src/exec.c
patch
|
blob
|
history
diff --git
a/src/exec.c
b/src/exec.c
index
82c7efa
..
5bddfc5
100644
(file)
--- a/
src/exec.c
+++ b/
src/exec.c
@@
-25,6
+25,7
@@
#include <sys/types.h>
#include <pwd.h>
#include <sys/types.h>
#include <pwd.h>
+#include <signal.h>
#include <pthread.h>
#include <pthread.h>
@@
-334,6
+335,7
@@
static void *exec_read_one (void *arg)
pl->pid = 0;
pthread_exit ((void *) 0);
pl->pid = 0;
pthread_exit ((void *) 0);
+ return (NULL);
} /* void *exec_read_one */
static int exec_read (void)
} /* void *exec_read_one */
static int exec_read (void)
@@
-356,6
+358,32
@@
static int exec_read (void)
return (0);
} /* int exec_read */
return (0);
} /* int exec_read */
+static int exec_shutdown (void)
+{
+ program_list_t *pl;
+ program_list_t *next;
+
+ pl = pl_head;
+ while (pl != NULL)
+ {
+ next = pl->next;
+
+ if (pl->pid > 0)
+ {
+ kill (pl->pid, SIGTERM);
+ INFO ("exec plugin: Sent SIGTERM to %hu", (unsigned short int) pl->pid);
+ }
+
+ sfree (pl->user);
+ sfree (pl);
+
+ pl = next;
+ } /* while (pl) */
+ pl_head = NULL;
+
+ return (0);
+} /* int exec_shutdown */
+
void module_register (modreg_e load)
{
if (load & MR_DATASETS)
void module_register (modreg_e load)
{
if (load & MR_DATASETS)
@@
-368,6
+396,7
@@
void module_register (modreg_e load)
{
plugin_register_config ("exec", exec_config, config_keys, config_keys_num);
plugin_register_read ("exec", exec_read);
{
plugin_register_config ("exec", exec_config, config_keys, config_keys_num);
plugin_register_read ("exec", exec_read);
+ plugin_register_shutdown ("exec", exec_shutdown);
}
} /* void module_register */
}
} /* void module_register */