From c089c920528313b72a535dabfcdbd91a66c8d977 Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Fri, 12 Nov 2010 08:13:42 +0100 Subject: [PATCH] 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. --- src/processes.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) 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; -- 2.11.0