summaryrefslogtreecommitdiff
path: root/src/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/util.c')
-rw-r--r--src/util.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/util.c b/src/util.c
index a1686ed389..5daafdf7c2 100644
--- a/src/util.c
+++ b/src/util.c
@@ -513,7 +513,16 @@ int write_one_line_file(const char *fn, const char *line) {
if (!endswith(line, "\n"))
fputc('\n', f);
- r = 0;
+ fflush(f);
+
+ if (ferror(f)) {
+ if (errno != 0)
+ r = -errno;
+ else
+ r = -EIO;
+ } else
+ r = 0;
+
finish:
fclose(f);
return r;