include/closestream: avoid close more than once
Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
parent
25b7045e5d
commit
52aa1a6611
|
@ -39,7 +39,7 @@ close_stream(FILE * stream)
|
||||||
static inline void
|
static inline void
|
||||||
close_stdout(void)
|
close_stdout(void)
|
||||||
{
|
{
|
||||||
if (close_stream(stdout) != 0 && !(errno == EPIPE)) {
|
if (stdout && close_stream(stdout) != 0 && !(errno == EPIPE)) {
|
||||||
if (errno)
|
if (errno)
|
||||||
warn(_("write error"));
|
warn(_("write error"));
|
||||||
else
|
else
|
||||||
|
@ -47,8 +47,11 @@ close_stdout(void)
|
||||||
_exit(CLOSE_EXIT_CODE);
|
_exit(CLOSE_EXIT_CODE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (close_stream(stderr) != 0)
|
if (stderr && close_stream(stderr) != 0)
|
||||||
_exit(CLOSE_EXIT_CODE);
|
_exit(CLOSE_EXIT_CODE);
|
||||||
|
|
||||||
|
stdout = NULL;
|
||||||
|
stderr = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
|
|
Loading…
Reference in New Issue