X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fprocesses.c;h=30798d42a6b76274608a6270c7481dddd3a17350;hb=66f9d645f883eee0aa408428eefdebdcc6dcfa7e;hp=8a3df644d00e71be94f343faaa65c3b29bd9aafb;hpb=c15dbfc3739f7c3bbd8171797eaef55749008bfa;p=collectd.git diff --git a/src/processes.c b/src/processes.c index 8a3df644..30798d42 100644 --- a/src/processes.c +++ b/src/processes.c @@ -999,13 +999,18 @@ static char *ps_get_cmdline (pid_t pid, char *name, char *buf, size_t buf_len) if ((pid < 1) || (NULL == buf) || (buf_len < 2)) return NULL; - ssnprintf (file, sizeof (file), "/proc/%u/cmdline", pid); + ssnprintf (file, sizeof (file), "/proc/%u/cmdline", + (unsigned int) pid); + errno = 0; fd = open (file, O_RDONLY); if (fd < 0) { char errbuf[4096]; - WARNING ("processes plugin: Failed to open `%s': %s.", file, - sstrerror (errno, errbuf, sizeof (errbuf))); + /* ENOENT means the process exited while we were handling it. + * Don't complain about this, it only fills the logs. */ + if (errno != ENOENT) + WARNING ("processes plugin: Failed to open `%s': %s.", file, + sstrerror (errno, errbuf, sizeof (errbuf))); return NULL; } @@ -1020,7 +1025,7 @@ static char *ps_get_cmdline (pid_t pid, char *name, char *buf, size_t buf_len) status = read (fd, (void *)buf_ptr, len); if (status < 0) { - char errbuf[4096]; + char errbuf[1024]; if ((EAGAIN == errno) || (EINTR == errno)) continue;