From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Blake Subject: Re: bash: Correct usage of F_SETFD Date: Mon, 22 Nov 2010 15:27:06 -0700 Message-ID: <4CEAEE3A.4090004@redhat.com> References: <20101122201620.GA16687@us.ibm.com> <101122221640.AA32947.SM@caleb.INS.CWRU.Edu> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="------------enigDD3B389042217978E010AFF8" Cc: linux-fsdevel@vger.kernel.org, sukadev@linux.vnet.ibm.com, bug-bash@gnu.org, chet@po.cwru.edu To: chet.ramey@case.edu Return-path: In-Reply-To: <101122221640.AA32947.SM@caleb.INS.CWRU.Edu> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: bug-bash-bounces+gnu-bug-bash-2=m.gmane.org@gnu.org Errors-To: bug-bash-bounces+gnu-bug-bash-2=m.gmane.org@gnu.org List-Id: linux-fsdevel.vger.kernel.org This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigDD3B389042217978E010AFF8 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On 11/22/2010 03:16 PM, Chet Ramey wrote: >> include/filecntl.h in bash-4.1 has following: >> >> #define SET_CLOSE_ON_EXEC(fd) (fcntl ((fd), F_SETFD, FD_CLOEXEC)) >> >> Is that really the correct/intended usage of F_SETFD ? >=20 > F_SETFD Set the close-on-exec flag associated with fild= es to > the low order bit of arg (0 or 1 as above). >=20 >> If kernel ever adds a new flag to the fd, this would end up clearing t= he >> other new flag right ? >> >> Shouldn't bash use F_GETFD to get the current flags and set/clear just= >> the FD_CLOEXEC bit ? >=20 > I suppose it would matter if there are systems that have more than one > flag value. In practice, there aren't any such systems; but POSIX warns that current practice is no indicator of future systems, and that read-modify-write is the only way to use F_SETFD. --=20 Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org --------------enigDD3B389042217978E010AFF8 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/ iQEcBAEBCAAGBQJM6u46AAoJEKeha0olJ0NqB7AH/iafB0aqmTynNfHqlNhwLgYr 0NfFWX2IUBSGVznqiaSYBUWBfsH9vrNDzWpq7DYmpaTbtgPrEPFFvQxwr4P3n0xK E9gN1qnr//uSUIs4W/v721mbrOLIQTNTD9Gi2NMAfzrSoSzj2Sq7zAU66IK21oDv KiHUavXKqmUfD+TS24bZZhZBh+KVylAHrPP9VgfSZUEsrqy/zwVDrglhs+xswV// 7CXTPkAdTkXxUMhp3nQMQEZghyDfg6y2VKwT2A8Fx7pBgw4k9FMpYma6VFf1Hq1I /AED2tLkz6226w6lCb/IJwS0buHvTseSIi1QrvB7atS4tMFPuvj0H9wuWH61Qu0= =HfW/ -----END PGP SIGNATURE----- --------------enigDD3B389042217978E010AFF8--