Date: Wed, 11 Jan 2012 00:06:07 +0100 From: Jilles Tjoelker <jilles@stack.nl> To: Guy Helmer <ghelmer@FreeBSD.org> 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: <20120110230607.GA15897@stack.nl> In-Reply-To: <201201101843.q0AIhRuM022949@svn.freebsd.org> References: <201201101843.q0AIhRuM022949@svn.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20120110230607.GA15897>