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
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to