Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 11 Jan 2012 10:36:09 -0600
From:      Guy Helmer <guy.helmer@palisadesystems.com>
To:        Jilles Tjoelker <jilles@stack.nl>
Cc:        svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org
Subject:   Re: svn commit: r229936 - head/lib/libutil
Message-ID:  <38F874EE-9573-4370-A3BD-DA08594023CD@palisadesystems.com>
In-Reply-To: <20120110230607.GA15897@stack.nl>
References:  <201201101843.q0AIhRuM022949@svn.freebsd.org> <20120110230607.GA15897@stack.nl>

next in thread | previous in thread | raw e-mail | index | archive | help
On Jan 10, 2012, at 5:06 PM, Jilles Tjoelker wrote:

> On Tue, Jan 10, 2012 at 06:43:27PM +0000, Guy Helmer wrote:
>> Author: ghelmer
>> Date: Tue Jan 10 18:43:27 2012
>> New Revision: 229936
>> URL: http://svn.freebsd.org/changeset/base/229936
> 
>> Log:
>>  Set the FD_CLOEXEC flag on the open pidfile file descriptor.
> 
>>  Discussed with: pjd, des
> 
>> Modified:
>>  head/lib/libutil/pidfile.c
> 
>> +	/*
>> +	 * Prevent the file descriptor from escaping to other
>> +	 * programs via exec(3).
>> +	 */
>> +	if (fcntl(fd, F_SETFD, FD_CLOEXEC) == -1) {
> 
> Consider adding O_CLOEXEC to the flopen() flags instead. That saves a
> system call and removes a possible race condition with fork/exec from
> threads or signal handlers.
> 
> -- 
> Jilles Tjoelker

Good idea, thanks!

Guy


--------
This message has been scanned by ComplianceSafe, powered by Palisade's PacketSure.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?38F874EE-9573-4370-A3BD-DA08594023CD>