projects
/
systemd
/
.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
112bed8
)
fd-util: be more careful with fclose() errnos
author
Lennart Poettering
<lennart@poettering.net>
Tue, 2 Jun 2020 08:39:25 +0000
(10:39 +0200)
committer
Lennart Poettering
<lennart@poettering.net>
Tue, 2 Jun 2020 15:32:02 +0000
(17:32 +0200)
This might fix #15859, a bug which I find very puzzling.
src/basic/fd-util.c
patch
|
blob
|
history
diff --git
a/src/basic/fd-util.c
b/src/basic/fd-util.c
index e2bee511478beab2fb5de276e9dcb08561e68e56..75a6282ed08d9e746b8612875031a89090d57f85 100644
(file)
--- a/
src/basic/fd-util.c
+++ b/
src/basic/fd-util.c
@@
-103,13
+103,16
@@
int fclose_nointr(FILE *f) {
/* Same as close_nointr(), but for fclose() */
+ errno = 0; /* Extra safety: if the FILE* object is not encapsulating an fd, it might not set errno
+ * correctly. Let's hence initialize it to zero first, so that we aren't confused by any
+ * prior errno here */
if (fclose(f) == 0)
return 0;
if (errno == EINTR)
return 0;
- return
-errno
;
+ return
errno_or_else(EIO)
;
}
FILE* safe_fclose(FILE *f) {