[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Why does close_stdout close stdout and stderr?
From: |
NeilBrown |
Subject: |
Re: Why does close_stdout close stdout and stderr? |
Date: |
Thu, 09 May 2019 16:27:34 +1000 |
On Wed, May 08 2019, Paul Eggert wrote:
> Florian Weimer wrote:
>>> You can achieve that "actual close call" using
>>>
>>> error = close(dup(fileno(stdout)));
>>>
>>> so you don't actually need to "fclose" if you don't want to.
>>> Any 'close' will do, it doesn't have to be the "last close".
>> Hah, thanks for this suggestion! So something good came out of this
>> thread after all. The big advantage of this approach is that this will
>> preserve the descriptor and the stream, so that further diagnostics from
>> the process are not suppressed.
>
> That trick won't work if the dup fails.
>
> Also, I worry that the trick won't port to non-Linux kernels, so it would
> have
> to be '#ifdef __linux__' or something like that.
Are there any non-Linux kernels ???
Seriously though, I suspect it would work on any Unix-like kernel.
It certainly doesn't hurt, so there is no need to protect it with the
#ifdef.
NeilBrown
signature.asc
Description: PGP signature
- Re: Why does close_stdout close stdout and stderr?, (continued)
- Re: Why does close_stdout close stdout and stderr?, Paul Eggert, 2019/05/06
- Re: Why does close_stdout close stdout and stderr?, Bruno Haible, 2019/05/06
- Re: Why does close_stdout close stdout and stderr?, Assaf Gordon, 2019/05/07
- Re: Why does close_stdout close stdout and stderr?, Assaf Gordon, 2019/05/07
- Re: Why does close_stdout close stdout and stderr?, Bruno Haible, 2019/05/07
- Re: Why does close_stdout close stdout and stderr?, NeilBrown, 2019/05/07
- Re: Why does close_stdout close stdout and stderr?, Florian Weimer, 2019/05/08
- Re: Why does close_stdout close stdout and stderr?, Paul Eggert, 2019/05/09
- Re: Why does close_stdout close stdout and stderr?, Florian Weimer, 2019/05/09
- Re: Why does close_stdout close stdout and stderr?,
NeilBrown <=