From mboxrd@z Thu Jan 1 00:00:00 1970 From: Chet Ramey Subject: Re: bash: Correct usage of F_SETFD Date: Mon, 22 Nov 2010 17:16:40 -0500 Message-ID: <101122221640.AA32947.SM@caleb.INS.CWRU.Edu> References: <20101122201620.GA16687@us.ibm.com> Reply-To: chet.ramey@case.edu Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: linux-fsdevel@vger.kernel.org, bug-bash@gnu.org, chet@po.cwru.edu To: sukadev@linux.vnet.ibm.com Return-path: In-Reply-To: Message from sukadev@linux.vnet.ibm.com of Mon, 22 Nov 2010 12:16:20 -0800 (id <20101122201620.GA16687@us.ibm.com>) 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 > 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 ? F_SETFD Set the close-on-exec flag associated with fildes to the low order bit of arg (0 or 1 as above). > If kernel ever adds a new flag to the fd, this would end up clearing the > other new flag right ? > > Shouldn't bash use F_GETFD to get the current flags and set/clear just > the FD_CLOEXEC bit ? I suppose it would matter if there are systems that have more than one flag value. Chet -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, ITS, CWRU chet@case.edu http://cnswww.cns.cwru.edu/~chet/