summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 552a974)
raw | patch | inline | side by side (parent: 552a974)
author | Florian Forster <octo@collectd.org> | |
Sat, 17 Mar 2012 10:34:43 +0000 (11:34 +0100) | ||
committer | Florian Forster <octo@collectd.org> | |
Sat, 17 Mar 2012 10:34:43 +0000 (11:34 +0100) |
src/processes.c | patch | blob | history |
diff --git a/src/processes.c b/src/processes.c
index e58076a3c83ad41d13b1d40dadaf3152c4d95606..3822d42c950dcc45da334c5793421da0207292d3 100644 (file)
--- a/src/processes.c
+++ b/src/processes.c
kvm_t *kd;
char errbuf[1024];
struct kinfo_proc *procs; /* array of processes */
- char **argv;
int count; /* returns number of processes */
int i;
* filter out threads (duplicate PID entries). */
if ((proc_ptr == NULL) || (proc_ptr->ki_pid != procs[i].ki_pid))
{
- char cmdline[ARG_MAX];
+ char cmdline[ARG_MAX] = "";
_Bool have_cmdline = 0;
- memset (cmdline, 0, sizeof (cmdline));
-
proc_ptr = &(procs[i]);
- /* not probe system processes and processes without arguments*/
+ /* Don't probe system processes and processes without arguments */
if (((procs[i].ki_flag & P_SYSTEM) == 0)
- && (procs[i].ki_args != NULL ))
+ && (procs[i].ki_args != NULL))
{
+ char **argv;
+ int argc;
+ int status;
+
/* retrieve the arguments */
argv = kvm_getargv (kd, proc_ptr, /* nchr = */ 0);
- if ( argv != NULL && *argv)
+ argc = 0;
+ if ((argv != NULL) && (argv[0] != NULL))
{
- int status;
- int argc;
-
- argc = 0;
while (argv[argc] != NULL)
argc++;
- status = strjoin (cmdline, sizeof (cmdline),
- argv, argc, " ");
-
+ status = strjoin (cmdline, sizeof (cmdline), argv, argc, " ");
if (status < 0)
WARNING ("processes plugin: Command line did not fit into buffer.");
else
have_cmdline = 1;
-
}
- }
+ } /* if (process has argument list) */
pse.id = procs[i].ki_pid;
pse.age = 0;