diff options
author | Lennart Poettering <lennart@poettering.net> | 2020-06-02 10:39:25 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2020-06-02 17:32:02 +0200 |
commit | 75f6d5d87e950f62baced48fe9b58828969e3811 (patch) | |
tree | 66d2ff4af85a405aa5ba4ca2c50642b915276f9d /src/basic/fd-util.c | |
parent | update TODO (diff) | |
download | systemd-75f6d5d87e950f62baced48fe9b58828969e3811.tar.xz systemd-75f6d5d87e950f62baced48fe9b58828969e3811.zip |
fd-util: be more careful with fclose() errnos
This might fix #15859, a bug which I find very puzzling.
Diffstat (limited to 'src/basic/fd-util.c')
-rw-r--r-- | src/basic/fd-util.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/basic/fd-util.c b/src/basic/fd-util.c index e2bee51147..75a6282ed0 100644 --- 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) { |