diff options
author | Karel Zak | 2019-06-13 13:25:44 +0200 |
---|---|---|
committer | Karel Zak | 2019-06-17 15:46:10 +0200 |
commit | 52aa1a661110e235a9eff57bb4db88aa8412dac1 (patch) | |
tree | 7410ca4cc0e228db6e191da54be000bafc71e17e | |
parent | misc: replaces atexit(close_stdout) with new close_stdout_atexit() (diff) | |
download | kernel-qcow2-util-linux-52aa1a661110e235a9eff57bb4db88aa8412dac1.tar.gz kernel-qcow2-util-linux-52aa1a661110e235a9eff57bb4db88aa8412dac1.tar.xz kernel-qcow2-util-linux-52aa1a661110e235a9eff57bb4db88aa8412dac1.zip |
include/closestream: avoid close more than once
Signed-off-by: Karel Zak <kzak@redhat.com>
-rw-r--r-- | include/closestream.h | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/include/closestream.h b/include/closestream.h index 6a62e48e8..83df1ee7d 100644 --- a/include/closestream.h +++ b/include/closestream.h @@ -39,7 +39,7 @@ close_stream(FILE * stream) static inline void close_stdout(void) { - if (close_stream(stdout) != 0 && !(errno == EPIPE)) { + if (stdout && close_stream(stdout) != 0 && !(errno == EPIPE)) { if (errno) warn(_("write error")); else @@ -47,8 +47,11 @@ close_stdout(void) _exit(CLOSE_EXIT_CODE); } - if (close_stream(stderr) != 0) + if (stderr && close_stream(stderr) != 0) _exit(CLOSE_EXIT_CODE); + + stdout = NULL; + stderr = NULL; } static inline void |