summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: cd98358)
raw | patch | inline | side by side (parent: cd98358)
author | Michał Mirosław <mirq-linux@rere.qmqm.pl> | |
Sat, 21 Jun 2008 20:21:56 +0000 (22:21 +0200) | ||
committer | Florian Forster <octo@huhu.verplant.org> | |
Tue, 24 Jun 2008 11:28:40 +0000 (13:28 +0200) |
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>
Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Signed-off-by: Florian Forster <octo@huhu.verplant.org>
src/processes.c | patch | blob | history |
diff --git a/src/processes.c b/src/processes.c
index 545967233eefe4a4aa041cc18e3c198db06862bc..c0d667d38ab14a15369a6b7e2469f81e72e164ba 100644 (file)
--- a/src/processes.c
+++ b/src/processes.c
{
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)