From owner-svn-src-all@FreeBSD.ORG Sat May 4 11:49:02 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id ABEA23A6; Sat, 4 May 2013 11:49:02 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 9E37215A9; Sat, 4 May 2013 11:49:02 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r44Bn2IQ047460; Sat, 4 May 2013 11:49:02 GMT (envelope-from jilles@svn.freebsd.org) Received: (from jilles@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r44Bn2ma047459; Sat, 4 May 2013 11:49:02 GMT (envelope-from jilles@svn.freebsd.org) Message-Id: <201305041149.r44Bn2ma047459@svn.freebsd.org> From: Jilles Tjoelker Date: Sat, 4 May 2013 11:49:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r250232 - stable/9/usr.sbin/syslogd X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 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: Sat, 04 May 2013 11:49:02 -0000 Author: jilles Date: Sat May 4 11:49:02 2013 New Revision: 250232 URL: http://svnweb.freebsd.org/changeset/base/250232 Log: MFC r249983: syslogd: Use closefrom() instead of getdtablesize()/close() loop. When syslogd forks a process for '|' destinations, it closes all file descriptors greater than 2. Use closefrom() for this instead of a getdtablesize()/close() loop because it is both faster and avoids leaving file descriptors open because the limit was lowered after they were opened. Modified: stable/9/usr.sbin/syslogd/syslogd.c Directory Properties: stable/9/usr.sbin/syslogd/ (props changed) Modified: stable/9/usr.sbin/syslogd/syslogd.c ============================================================================== --- stable/9/usr.sbin/syslogd/syslogd.c Sat May 4 11:45:48 2013 (r250231) +++ stable/9/usr.sbin/syslogd/syslogd.c Sat May 4 11:49:02 2013 (r250232) @@ -2476,7 +2476,7 @@ validate(struct sockaddr *sa, const char static int p_open(const char *prog, pid_t *rpid) { - int pfd[2], nulldesc, i; + int pfd[2], nulldesc; pid_t pid; sigset_t omask, mask; char *argv[4]; /* sh -c cmd NULL */ @@ -2526,8 +2526,7 @@ p_open(const char *prog, pid_t *rpid) dup2(pfd[0], STDIN_FILENO); dup2(nulldesc, STDOUT_FILENO); dup2(nulldesc, STDERR_FILENO); - for (i = getdtablesize(); i > 2; i--) - (void)close(i); + closefrom(3); (void)execvp(_PATH_BSHELL, argv); _exit(255);