X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Fexec.c;h=c64f949fc57b4ac5cff424a6b27e7cd283e13184;hb=c4d3c868482aa6dbb3cf96685ce7d1cc1a70c995;hp=3bd6309fb24b5a3f68378e9e73bdc227d1cc0c10;hpb=67e4e517f58dac2a7b0e63b80256231480bfa59d;p=collectd.git diff --git a/src/exec.c b/src/exec.c index 3bd6309f..c64f949f 100644 --- a/src/exec.c +++ b/src/exec.c @@ -1,6 +1,6 @@ /** * collectd - src/exec.c - * Copyright (C) 2007-2009 Florian octo Forster + * Copyright (C) 2007-2010 Florian octo Forster * Copyright (C) 2007-2009 Sebastian Harl * Copyright (C) 2008 Peter Holik * @@ -269,13 +269,26 @@ static void set_environment (void) /* {{{ */ { char buffer[1024]; +#ifdef HAVE_SETENV ssnprintf (buffer, sizeof (buffer), "%i", interval_g); setenv ("COLLECTD_INTERVAL", buffer, /* overwrite = */ 1); ssnprintf (buffer, sizeof (buffer), "%s", hostname_g); setenv ("COLLECTD_HOSTNAME", buffer, /* overwrite = */ 1); +#else + ssnprintf (buffer, sizeof (buffer), "COLLECTD_INTERVAL=%i", interval_g); + putenv (buffer); + + ssnprintf (buffer, sizeof (buffer), "COLLECTD_HOSTNAME=%s", hostname_g); + putenv (buffer); +#endif + +#ifdef HAVE_SETENV +#else +#endif } /* }}} void set_environment */ +__attribute__((noreturn)) static void exec_child (program_list_t *pl) /* {{{ */ { int status; @@ -550,7 +563,13 @@ static void *exec_read_one (void *arg) /* {{{ */ status = fork_child (pl, NULL, &fd, &fd_err); if (status < 0) + { + /* Reset the "running" flag */ + pthread_mutex_lock (&pl_lock); + pl->flags &= ~PL_RUNNING; + pthread_mutex_unlock (&pl_lock); pthread_exit ((void *) 1); + } pl->pid = status; assert (pl->pid != 0); @@ -806,7 +825,7 @@ static int exec_read (void) /* {{{ */ return (0); } /* int exec_read }}} */ -static int exec_notification (const notification_t *n, +static int exec_notification (const notification_t *n, /* {{{ */ user_data_t __attribute__((unused)) *user_data) { program_list_t *pl;