From owner-svn-src-all@FreeBSD.ORG Wed Jan 11 23:52:16 2012 Return-Path: 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 201C51065677; Wed, 11 Jan 2012 23:52:16 +0000 (UTC) (envelope-from pawel@dawidek.net) Received: from mail.dawidek.net (60.wheelsystems.com [83.12.187.60]) by mx1.freebsd.org (Postfix) with ESMTP id C352F8FC16; Wed, 11 Jan 2012 23:52:15 +0000 (UTC) Received: from localhost (89-73-195-149.dynamic.chello.pl [89.73.195.149]) by mail.dawidek.net (Postfix) with ESMTPSA id B506931B; Thu, 12 Jan 2012 00:52:13 +0100 (CET) Date: Thu, 12 Jan 2012 00:51:06 +0100 From: Pawel Jakub Dawidek To: Guy Helmer Message-ID: <20120111235105.GG1695@garage.freebsd.pl> References: <201201111635.q0BGZQmQ067528@svn.freebsd.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="c7hkjup166d4FzgN" Content-Disposition: inline In-Reply-To: <201201111635.q0BGZQmQ067528@svn.freebsd.org> X-OS: FreeBSD 9.0-CURRENT amd64 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: r229966 - 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" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Jan 2012 23:52:16 -0000 --c7hkjup166d4FzgN Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Jan 11, 2012 at 04:35:26PM +0000, Guy Helmer wrote: > Author: ghelmer > Date: Wed Jan 11 16:35:26 2012 > New Revision: 229966 > URL: http://svn.freebsd.org/changeset/base/229966 >=20 > Log: > jilles pointed out that O_CLOEXEC could be used in the open(2) flags > rather than using fcntl(2) later, and in addition to saving a system > call, removes a possible race with fork/exec from threads or signal > handlers. So now we can remove fcntl() as the source of possible pidfile_open() errnos from the manual page.:) > Modified: > head/lib/libutil/pidfile.c >=20 > Modified: head/lib/libutil/pidfile.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- head/lib/libutil/pidfile.c Wed Jan 11 15:00:16 2012 (r229965) > +++ head/lib/libutil/pidfile.c Wed Jan 11 16:35:26 2012 (r229966) > @@ -117,7 +117,7 @@ pidfile_open(const char *path, mode_t mo > * pidfile_write() can be called multiple times. > */ > fd =3D flopen(pfh->pf_path, > - O_WRONLY | O_CREAT | O_TRUNC | O_NONBLOCK, mode); > + O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC | O_NONBLOCK, mode); > if (fd =3D=3D -1) { > if (errno =3D=3D EWOULDBLOCK && pidptr !=3D NULL) { > count =3D 20; > @@ -139,19 +139,6 @@ pidfile_open(const char *path, mode_t mo > } > =20 > /* > - * Prevent the file descriptor from escaping to other > - * programs via exec(3). > - */ > - if (fcntl(fd, F_SETFD, FD_CLOEXEC) =3D=3D -1) { > - error =3D errno; > - unlink(pfh->pf_path); > - close(fd); > - free(pfh); > - errno =3D error; > - return (NULL); > - } > - > - /* > * Remember file information, so in pidfile_write() we are sure we write > * to the proper descriptor. > */ --=20 Pawel Jakub Dawidek http://www.wheelsystems.com FreeBSD committer http://www.FreeBSD.org Am I Evil? Yes, I Am! http://yomoli.com --c7hkjup166d4FzgN Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.14 (FreeBSD) iEYEARECAAYFAk8OIGgACgkQForvXbEpPzRXQwCg5FNVDhxiSmijXULpq0L2J58R GGgAoNxBvH2gmTYnJeMQCoursyuLSUfK =RZlq -----END PGP SIGNATURE----- --c7hkjup166d4FzgN--