gnupg_reopen_std - descriptor state problem

Marcin Gryszkalis mg at
Mon Sep 10 10:30:43 CEST 2018


On 2018-09-07 04:58, NIIBE Yutaka wrote:
> Interesting.  Probably, the stdin is connected to the socket (which may
> be already shutdown-ed), I don't know.

That's possible.

> It seems that stdout is connected to named pipe, btw.
That's possible too.

>> I can't see any problems additional close() could cause - but I'm not 
>> sure
>> about all unix plaftorms.
> I think that doing any operation on the fd (which retured EBADF) sounds
> not healthy (even if it's close(2)).

I had similar feeling :)

> I wonder if changes like following make sense to see if fd is valid or
> not.  My theory is that fcntl is cheaper/simpler operation then fstat,
> and might be better in this case.

I'll test the patch and report - but I wonder why you decided to use 
F_GETFD (and
not for example F_GETFL?

best regards
Marcin Gryszkalis, PGP 0xA5DBEEC7
jabber jid:mg at

More information about the Gnupg-devel mailing list