summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichal Schmidt <mschmidt@redhat.com>2011-12-03 00:41:34 +0100
committerMichal Schmidt <mschmidt@redhat.com>2011-12-03 02:08:52 +0100
commit35d50f55f346c71fd5e957d35ebcae1c50b1f9ce (patch)
treef1053be62b68ec4813ee494e00377fdbc43f254c /src
parent91b684c7300879a8d2006038f7d9185d92c3c3bf (diff)
util: fix error checking after fgets()
fgets() does not set errno on EOF.
Diffstat (limited to 'src')
-rw-r--r--src/util.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/util.c b/src/util.c
index e93e6f6cf5..da71e4d08b 100644
--- a/src/util.c
+++ b/src/util.c
@@ -516,7 +516,7 @@ int get_parent_of_pid(pid_t pid, pid_t *_ppid) {
return -errno;
if (!(fgets(line, sizeof(line), f))) {
- r = -errno;
+ r = feof(f) ? -EIO : -errno;
fclose(f);
return r;
}
@@ -561,7 +561,7 @@ int get_starttime_of_pid(pid_t pid, unsigned long long *st) {
return -errno;
if (!(fgets(line, sizeof(line), f))) {
- r = -errno;
+ r = feof(f) ? -EIO : -errno;
fclose(f);
return r;
}
@@ -708,7 +708,7 @@ int read_one_line_file(const char *fn, char **line) {
return -errno;
if (!(fgets(t, sizeof(t), f))) {
- r = -errno;
+ r = feof(f) ? -EIO : -errno;
goto finish;
}
@@ -3266,7 +3266,7 @@ int get_ctty_devnr(pid_t pid, dev_t *d) {
return -errno;
if (!fgets(line, sizeof(line), f)) {
- k = -errno;
+ k = feof(f) ? -EIO : -errno;
fclose(f);
return k;
}