projects
/
collectd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
apache plugin: Fix collection of the "apache_connections" value with Apache 2.*.
[collectd.git]
/
src
/
exec.c
diff --git
a/src/exec.c
b/src/exec.c
index
d2b2508
..
3a72eba
100644
(file)
--- a/
src/exec.c
+++ b/
src/exec.c
@@
-23,6
+23,8
@@
* Peter Holik <peter at holik.at>
**/
* Peter Holik <peter at holik.at>
**/
+#define _BSD_SOURCE /* For setgroups */
+
#include "collectd.h"
#include "common.h"
#include "plugin.h"
#include "collectd.h"
#include "common.h"
#include "plugin.h"
@@
-279,8
+281,8
@@
static void exec_child (program_list_t *pl) /* {{{ */
status = getpwnam_r (pl->user, &sp, nambuf, sizeof (nambuf), &sp_ptr);
if (status != 0)
{
status = getpwnam_r (pl->user, &sp, nambuf, sizeof (nambuf), &sp_ptr);
if (status != 0)
{
- ERROR ("exec plugin:
getpwnam_r failed
: %s",
- sstrerror (errno, errbuf, sizeof (errbuf)));
+ ERROR ("exec plugin:
Failed to get user information for user ``%s''
: %s",
+
pl->user,
sstrerror (errno, errbuf, sizeof (errbuf)));
exit (-1);
}
if (sp_ptr == NULL)
exit (-1);
}
if (sp_ptr == NULL)
@@
-309,7
+311,8
@@
static void exec_child (program_list_t *pl) /* {{{ */
status = getgrnam_r (pl->group, &gr, nambuf, sizeof (nambuf), &gr_ptr);
if (0 != status)
{
status = getgrnam_r (pl->group, &gr, nambuf, sizeof (nambuf), &gr_ptr);
if (0 != status)
{
- ERROR ("exec plugin: getgrnam_r failed: %s",
+ ERROR ("exec plugin: Failed to get group information "
+ "for group ``%s'': %s", pl->group,
sstrerror (errno, errbuf, sizeof (errbuf)));
exit (-1);
}
sstrerror (errno, errbuf, sizeof (errbuf)));
exit (-1);
}
@@
-375,11
+378,20
@@
static void exec_child (program_list_t *pl) /* {{{ */
status = execvp (pl->exec, pl->argv);
status = execvp (pl->exec, pl->argv);
- ERROR ("exec plugin:
exec failed
: %s",
- sstrerror (errno, errbuf, sizeof (errbuf)));
+ ERROR ("exec plugin:
Failed to execute ``%s''
: %s",
+
pl->exec,
sstrerror (errno, errbuf, sizeof (errbuf)));
exit (-1);
} /* void exec_child }}} */
exit (-1);
} /* void exec_child }}} */
+static void reset_signal_mask (void) /* {{{ */
+{
+ sigset_t ss;
+
+ memset (&ss, 0, sizeof (ss));
+ sigemptyset (&ss);
+ sigprocmask (SIG_SETMASK, &ss, /* old mask = */ NULL);
+} /* }}} void reset_signal_mask */
+
/*
* Creates three pipes (one for reading, one for writing and one for errors),
* forks a child, sets up the pipes so that fd_in is connected to STDIN of
/*
* Creates three pipes (one for reading, one for writing and one for errors),
* forks a child, sets up the pipes so that fd_in is connected to STDIN of
@@
-466,6
+478,9
@@
static int fork_child (program_list_t *pl, int *fd_in, int *fd_out, int *fd_err)
close (fd_pipe_err[1]);
}
close (fd_pipe_err[1]);
}
+ /* Unblock all signals */
+ reset_signal_mask ();
+
exec_child (pl);
/* does not return */
}
exec_child (pl);
/* does not return */
}
@@
-728,7
+743,8
@@
static void *exec_notification_one (void *arg) /* {{{ */
DEBUG ("exec plugin: Child %i exited with status %i.",
pid, status);
DEBUG ("exec plugin: Child %i exited with status %i.",
pid, status);
- plugin_notification_meta_free (n->meta);
+ if (n->meta != NULL)
+ plugin_notification_meta_free (n->meta);
n->meta = NULL;
sfree (arg);
pthread_exit ((void *) 0);
n->meta = NULL;
sfree (arg);
pthread_exit ((void *) 0);