From ce140b198884909f060dcdf5bfb7fac8799f50ea Mon Sep 17 00:00:00 2001 From: =?utf8?q?Micha=C5=82=20Miros=C5=82aw?= Date: Sat, 21 Jun 2008 22:21:56 +0200 Subject: [PATCH] processes plugin: Use read_file_contents(). MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit src/processes.c: use read_file_contents() Signed-off-by: Michał Mirosław Signed-off-by: Florian Forster --- src/processes.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/processes.c b/src/processes.c index 54596723..c0d667d3 100644 --- a/src/processes.c +++ b/src/processes.c @@ -644,7 +644,6 @@ int ps_read_process (int pid, procstat_t *ps, char *state) { char filename[64]; char buffer[1024]; - FILE *fh; char *fields[64]; char fields_len; @@ -663,16 +662,10 @@ int ps_read_process (int pid, procstat_t *ps, char *state) ssnprintf (filename, sizeof (filename), "/proc/%i/stat", pid); - if ((fh = fopen (filename, "r")) == NULL) + i = read_file_contents (filename, buffer, sizeof(buffer) - 1); + if (i <= 0) return (-1); - - if (fgets (buffer, 1024, fh) == NULL) - { - fclose (fh); - return (-1); - } - - fclose (fh); + buffer[i] = 0; fields_len = strsplit (buffer, fields, 64); if (fields_len < 24) -- 2.11.0