summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 010cdc7)
raw | patch | inline | side by side (parent: 010cdc7)
author | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Fri, 28 Dec 2007 20:02:55 +0000 (21:02 +0100) | ||
committer | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Fri, 28 Dec 2007 20:02:55 +0000 (21:02 +0100) |
src/exec.c | patch | blob | history |
diff --git a/src/exec.c b/src/exec.c
index 288e18ee52077648247a9ef6bc0c38ef536337de..df912a6c49782884247541b1ba46cda027f767f0 100644 (file)
--- a/src/exec.c
+++ b/src/exec.c
typedef struct program_list_and_notification_s
{
program_list_t *pl;
- const notification_t *n;
+ notification_t n;
} program_list_and_notification_t;
/*
static void *exec_notification_one (void *arg) /* {{{ */
{
program_list_t *pl = ((program_list_and_notification_t *) arg)->pl;
- const notification_t *n = ((program_list_and_notification_t *) arg)->n;
+ const notification_t *n = &((program_list_and_notification_t *) arg)->n;
int fd;
FILE *fh;
int pid;
DEBUG ("exec plugin: Child %i exited with status %i.",
pid, status);
+ sfree (arg);
pthread_exit ((void *) 0);
return (NULL);
} /* void *exec_notification_one }}} */
static int exec_notification (const notification_t *n)
{
program_list_t *pl;
+ program_list_and_notification_t *pln;
for (pl = pl_head; pl != NULL; pl = pl->next)
{
pthread_t t;
pthread_attr_t attr;
- /* Only execute `normal' and `nagios' style executables here. */
+ /* Only execute `notification' style executables here. */
if ((pl->flags & PL_NOTIF_ACTION) == 0)
continue;
if (pl->pid != 0)
continue;
+ pln = (program_list_and_notification_t *) malloc (sizeof
+ (program_list_and_notification_t));
+ if (pln == NULL)
+ {
+ ERROR ("exec plugin: malloc failed.");
+ continue;
+ }
+
+ pln->pl = pl;
+ memcpy (&pln->n, n, sizeof (notification_t));
+
pthread_attr_init (&attr);
pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED);
- pthread_create (&t, &attr, exec_notification_one, (void *) pl);
+ pthread_create (&t, &attr, exec_notification_one, (void *) pln);
} /* for (pl) */
return (0);