[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Why does close_stdout close stdout and stderr?

From: Florian Weimer
Subject: Re: Why does close_stdout close stdout and stderr?
Date: Thu, 09 May 2019 07:01:59 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux)

* Paul Eggert:

> 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.

You can do an fsync in this case.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]