-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 According to Bruno Haible on 11/22/2009 5:32 AM: > Eric Blake wrote on 2009-07-18: >> fileno(stdout) == 1 by definition of STDOUT_FILENO, so you don't >> have to go via fileno (you can directly use fcntl(1,...) to learn whether >> the fd has been closed). > > But the user might have called freopen (..., stdout). In this case, > fileno (stdout) will no longer be 1.
That is ONLY possible if both: stdin was closed the user is not using freopen_safer in which case the fd will be 0 instead of 1. There is no way for freopen() to ever make fileno(stdout) ever be greater than 1. > So you actually do have to use > fileno (stdout) in the patch that you committed on 2009-07-18 > <http://lists.gnu.org/archive/html/bug-gnulib/2009-07/msg00040.html> > > Here is a proposed patch: I'd rather make the patch conditional on whether freopen_safer is also in use. - -- Don't work too hard, make some time for fun as well! Eric Blake e...@byu.net -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (Cygwin) Comment: Public key at home.comcast.net/~ericblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAksJUaUACgkQ84KuGfSFAYABCQCfQQc1WDE++goK3Ku01QdNXGQo DDMAnj8tkxZZhFCYtkwF5KH7Vvu80VwO =bynP -----END PGP SIGNATURE-----