summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 1c72a0f)
raw | patch | inline | side by side (parent: 1c72a0f)
author | Florian Forster <octo@collectd.org> | |
Fri, 17 Feb 2012 14:09:26 +0000 (15:09 +0100) | ||
committer | Florian Forster <octo@collectd.org> | |
Fri, 17 Feb 2012 14:09:26 +0000 (15:09 +0100) |
Change-Id: I6e623f237c1d79007bd471732476a4e32dafde97
src/exec.c | patch | blob | history |
diff --git a/src/exec.c b/src/exec.c
index c48d85f5d4899bcafa00dff5356cfff3973f75a2..34c88a1ce6eb65e801bed579da1ea57e72a2e8b7 100644 (file)
--- a/src/exec.c
+++ b/src/exec.c
program_list_t *pl;
for (pl = pl_head; pl != NULL; pl = pl->next)
if (pl->pid == pid)
- break;
+ break;
if (pl != NULL)
pl->status = status;
} /* while (waitpid) */
if (ci->children_num != 0)
{
WARNING ("exec plugin: The config option `%s' may not be a block.",
- ci->key);
+ ci->key);
return (-1);
}
if (ci->values_num < 2)
{
WARNING ("exec plugin: The config option `%s' needs at least two "
- "arguments.", ci->key);
+ "arguments.", ci->key);
return (-1);
}
if ((ci->values[0].type != OCONFIG_TYPE_STRING)
|| (ci->values[1].type != OCONFIG_TYPE_STRING))
{
WARNING ("exec plugin: The first two arguments to the `%s' option must "
- "be string arguments.", ci->key);
+ "be string arguments.", ci->key);
return (-1);
}
{
if (ci->values[i + 1].type == OCONFIG_TYPE_NUMBER)
{
- ssnprintf (buffer, sizeof (buffer), "%lf",
- ci->values[i + 1].value.number);
+ ssnprintf (buffer, sizeof (buffer), "%lf",
+ ci->values[i + 1].value.number);
}
else
{
- if (ci->values[i + 1].value.boolean)
- sstrncpy (buffer, "true", sizeof (buffer));
- else
- sstrncpy (buffer, "false", sizeof (buffer));
+ if (ci->values[i + 1].value.boolean)
+ sstrncpy (buffer, "true", sizeof (buffer));
+ else
+ sstrncpy (buffer, "false", sizeof (buffer));
}
pl->argv[i] = strdup (buffer);
{
oconfig_item_t *child = ci->children + i;
if ((strcasecmp ("Exec", child->key) == 0)
- || (strcasecmp ("NotificationExec", child->key) == 0))
+ || (strcasecmp ("NotificationExec", child->key) == 0))
exec_config_exec (child);
else
{
if (status != 0)
{
ERROR ("exec plugin: Failed to get user information for user ``%s'': %s",
- pl->user, sstrerror (errno, errbuf, sizeof (errbuf)));
+ pl->user, sstrerror (errno, errbuf, sizeof (errbuf)));
exit (-1);
}
if (sp_ptr == NULL)
status = getgrnam_r (pl->group, &gr, nambuf, sizeof (nambuf), &gr_ptr);
if (0 != status)
{
- ERROR ("exec plugin: Failed to get group information "
- "for group ``%s'': %s", pl->group,
- sstrerror (errno, errbuf, sizeof (errbuf)));
- exit (-1);
+ ERROR ("exec plugin: Failed to get group information "
+ "for group ``%s'': %s", pl->group,
+ sstrerror (errno, errbuf, sizeof (errbuf)));
+ exit (-1);
}
if (NULL == gr_ptr)
{
- ERROR ("exec plugin: No such group: `%s'", pl->group);
- exit (-1);
+ ERROR ("exec plugin: No such group: `%s'", pl->group);
+ exit (-1);
}
egid = gr.gr_gid;
if (status != 0)
{
ERROR ("exec plugin: setgid (%i) failed: %s",
- gid, sstrerror (errno, errbuf, sizeof (errbuf)));
+ gid, sstrerror (errno, errbuf, sizeof (errbuf)));
exit (-1);
}
if (status != 0)
{
ERROR ("exec plugin: setegid (%i) failed: %s",
- egid, sstrerror (errno, errbuf, sizeof (errbuf)));
+ egid, sstrerror (errno, errbuf, sizeof (errbuf)));
exit (-1);
}
}
if (status != 0)
{
ERROR ("exec plugin: setuid (%i) failed: %s",
- uid, sstrerror (errno, errbuf, sizeof (errbuf)));
+ uid, sstrerror (errno, errbuf, sizeof (errbuf)));
exit (-1);
}
@@ -434,7 +434,7 @@ static int fork_child (program_list_t *pl, int *fd_in, int *fd_out, int *fd_err)
if (status != 0)
{
ERROR ("exec plugin: pipe failed: %s",
- sstrerror (errno, errbuf, sizeof (errbuf)));
+ sstrerror (errno, errbuf, sizeof (errbuf)));
return (-1);
}
@@ -442,7 +442,7 @@ static int fork_child (program_list_t *pl, int *fd_in, int *fd_out, int *fd_err)
if (status != 0)
{
ERROR ("exec plugin: pipe failed: %s",
- sstrerror (errno, errbuf, sizeof (errbuf)));
+ sstrerror (errno, errbuf, sizeof (errbuf)));
return (-1);
}
@@ -450,7 +450,7 @@ static int fork_child (program_list_t *pl, int *fd_in, int *fd_out, int *fd_err)
if (status != 0)
{
ERROR ("exec plugin: pipe failed: %s",
- sstrerror (errno, errbuf, sizeof (errbuf)));
+ sstrerror (errno, errbuf, sizeof (errbuf)));
return (-1);
}
@@ -458,7 +458,7 @@ static int fork_child (program_list_t *pl, int *fd_in, int *fd_out, int *fd_err)
if (pid < 0)
{
ERROR ("exec plugin: fork failed: %s",
- sstrerror (errno, errbuf, sizeof (errbuf)));
+ sstrerror (errno, errbuf, sizeof (errbuf)));
return (-1);
}
else if (pid == 0)
@@ -471,9 +471,9 @@ static int fork_child (program_list_t *pl, int *fd_in, int *fd_out, int *fd_err)
for (fd = 0; fd < fd_num; fd++)
{
if ((fd == fd_pipe_in[0])
- || (fd == fd_pipe_out[1])
- || (fd == fd_pipe_err[1]))
- continue;
+ || (fd == fd_pipe_out[1])
+ || (fd == fd_pipe_err[1]))
+ continue;
close (fd);
}
if (status < 0)
{
if (errno == EINTR)
- continue;
+ continue;
break;
}
}
else if (len == 0)
{
- /* We've reached EOF */
- NOTICE ("exec plugin: Program `%s' has closed STDERR.",
- pl->exec);
- close (fd_err);
- FD_CLR (fd_err, &fdset);
- highest_fd = fd;
- fd_err = -1;
- continue;
+ /* We've reached EOF */
+ NOTICE ("exec plugin: Program `%s' has closed STDERR.",
+ pl->exec);
+ close (fd_err);
+ FD_CLR (fd_err, &fdset);
+ highest_fd = fd;
+ fd_err = -1;
+ continue;
}
pbuffer_err[len] = '\0';
{
char errbuf[1024];
ERROR ("exec plugin: fdopen (%i) failed: %s", fd,
- sstrerror (errno, errbuf, sizeof (errbuf)));
+ sstrerror (errno, errbuf, sizeof (errbuf)));
kill (pl->pid, SIGTERM);
pl->pid = 0;
close (fd);
fprintf (fh, "%s: %e\n", meta->name, meta->nm_value.nm_double);
else if (meta->type == NM_TYPE_BOOLEAN)
fprintf (fh, "%s: %s\n", meta->name,
- meta->nm_value.nm_boolean ? "true" : "false");
+ meta->nm_value.nm_boolean ? "true" : "false");
}
fprintf (fh, "\n%s\n", n->message);
continue;
pln = (program_list_and_notification_t *) malloc (sizeof
- (program_list_and_notification_t));
+ (program_list_and_notification_t));
if (pln == NULL)
{
ERROR ("exec plugin: malloc failed.");