From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Blake Subject: Re: bash: Correct usage of F_SETFD Date: Tue, 23 Nov 2010 07:51:58 -0700 Message-ID: <4CEBD50E.7050405@redhat.com> References: <20101122201620.GA16687@us.ibm.com> <101122221640.AA32947.SM@caleb.INS.CWRU.Edu> <4CEAEE3A.4090004@redhat.com> <20101123000446.GA24667@us.ibm.com> <20101123144239.GL6178@parisc-linux.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="------------enig007C30A5CAE485BF2A01585B" Cc: Sukadev Bhattiprolu , chet.ramey@case.edu, linux-fsdevel@vger.kernel.org, bug-bash@gnu.org, chet@po.cwru.edu To: Matthew Wilcox Return-path: Received: from mx1.redhat.com ([209.132.183.28]:29354 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752952Ab0KWOwO (ORCPT ); Tue, 23 Nov 2010 09:52:14 -0500 In-Reply-To: <20101123144239.GL6178@parisc-linux.org> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig007C30A5CAE485BF2A01585B Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On 11/23/2010 07:42 AM, Matthew Wilcox wrote: > The POSIX definition can be found here: > http://www.opengroup.org/onlinepubs/009695399/functions/fcntl.html >=20 >> | In practice, there aren't any such systems; but POSIX warns that cur= rent >> | practice is no indicator of future systems, and that read-modify-wri= te >> | is the only way to use F_SETFD. >> >> Yes, that seems to make more sense. >=20 > I think future flags will be created such that they default to off, > and bash would have to affirmitively set them in order to use them. Not true. An implementation can reasonably define a new flag to off for backwards-compatible behavior, and on for POSIX-compatible behavior, if there is a case where traditional and POSIX behavior differ. POSIX permits additional bits to be on, and in fact requires that applications leave those additional bits unchanged, in the very case where those additional bits are essential for maintaining a POSIX-compatible environment. >=20 > So if bash is the one creating its file descriptors, there's no need to= > use R/M/W since it knows what the state of them are. No, bash cannot reasonably know what the implementation's default bit state is, and blindly setting all other bits to zero is very possibly a bug, and easy enough to avoid by using the full R/M/W. --=20 Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org --------------enig007C30A5CAE485BF2A01585B Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/ iQEcBAEBCAAGBQJM69UOAAoJEKeha0olJ0NqbfwH/2yYpezRWikLPWY3jzu9wI5B 7GvGNHwoLKtebyAqnz+FkpMUwzDCsWas/CoZviUbVfi53ZFa1PHuN752grEl4PzW tDDBoVXMj3AFg1CHwxRAHItHdRu2z//z7EgE85Vvp36VHkpSUyutHKtotXhQNbk2 FIUh8flOInOCU5U+IQ0CkM9tRhq0Tc0hVhdmvo4aDHXwxx9MJdUse0xMP+moRO6N Yb/bjXa4bwkTkpLFht6SzrGRDjSmTJ1c+1hKWUQhS7bsBzKQRm0teVWcAReKwThw YYq8Ly5C1puIFGnu1TFkWa4oIIt7l0+Sy9nx55mrHfGAMtl9azQoBYagqv4jndc= =VlPO -----END PGP SIGNATURE----- --------------enig007C30A5CAE485BF2A01585B--