From owner-svn-src-all@FreeBSD.ORG Tue Jan 10 23:06:10 2012 Return-Path: <owner-svn-src-all@FreeBSD.ORG> Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7F2961065670; Tue, 10 Jan 2012 23:06:10 +0000 (UTC) (envelope-from jilles@stack.nl) Received: from mx1.stack.nl (relay04.stack.nl [IPv6:2001:610:1108:5010::107]) by mx1.freebsd.org (Postfix) with ESMTP id E95BE8FC12; Tue, 10 Jan 2012 23:06:09 +0000 (UTC) Received: from snail.stack.nl (snail.stack.nl [IPv6:2001:610:1108:5010::131]) by mx1.stack.nl (Postfix) with ESMTP id CD1CD1DD607; Wed, 11 Jan 2012 00:06:07 +0100 (CET) Received: by snail.stack.nl (Postfix, from userid 1677) id AF65E28468; Wed, 11 Jan 2012 00:06:07 +0100 (CET) Date: Wed, 11 Jan 2012 00:06:07 +0100 From: Jilles Tjoelker <jilles@stack.nl> To: Guy Helmer <ghelmer@FreeBSD.org> Message-ID: <20120110230607.GA15897@stack.nl> References: <201201101843.q0AIhRuM022949@svn.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201201101843.q0AIhRuM022949@svn.freebsd.org> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r229936 - head/lib/libutil X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" <svn-src-all.freebsd.org> List-Unsubscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-all>, <mailto:svn-src-all-request@freebsd.org?subject=unsubscribe> List-Archive: <http://lists.freebsd.org/pipermail/svn-src-all> List-Post: <mailto:svn-src-all@freebsd.org> List-Help: <mailto:svn-src-all-request@freebsd.org?subject=help> List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-all>, <mailto:svn-src-all-request@freebsd.org?subject=subscribe> X-List-Received-Date: Tue, 10 Jan 2012 23:06:10 -0000 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