src/processes.c: use read_file_contents()
Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Signed-off-by: Florian Forster <octo@huhu.verplant.org>
{
char filename[64];
char buffer[1024];
- FILE *fh;
char *fields[64];
char fields_len;
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)