From: Florian Forster Date: Fri, 12 Nov 2010 07:13:42 +0000 (+0100) Subject: processes plugin: Don't complain about a failed open(/proc/$PID/cmdline) X-Git-Tag: collectd-4.9.4~4 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=c089c920528313b72a535dabfcdbd91a66c8d977;p=collectd.git processes plugin: Don't complain about a failed open(/proc/$PID/cmdline) ... if the error is ENOENT. This merely means we were too slow and that we can safely ignore the process. --- diff --git a/src/processes.c b/src/processes.c index 670aa8d7..856296cc 100644 --- a/src/processes.c +++ b/src/processes.c @@ -903,13 +903,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; } @@ -924,7 +929,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;