From: Karel Zak Date: Thu, 13 Jun 2019 11:25:44 +0000 (+0200) Subject: include/closestream: avoid close more than once X-Git-Tag: v2.35-rc1~329 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=52aa1a661110e235a9eff57bb4db88aa8412dac1;p=thirdparty%2Futil-linux.git include/closestream: avoid close more than once Signed-off-by: Karel Zak --- diff --git a/include/closestream.h b/include/closestream.h index 6a62e48e8a..83df1ee7d9 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