Date: Sat, 27 Apr 2013 13:26:36 +0000 (UTC) From: Jilles Tjoelker <jilles@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r249983 - head/usr.sbin/syslogd Message-ID: <201304271326.r3RDQaFC099151@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: jilles Date: Sat Apr 27 13:26:35 2013 New Revision: 249983 URL: http://svnweb.freebsd.org/changeset/base/249983 Log: 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. MFC after: 1 week Modified: head/usr.sbin/syslogd/syslogd.c Modified: head/usr.sbin/syslogd/syslogd.c ============================================================================== --- head/usr.sbin/syslogd/syslogd.c Sat Apr 27 12:50:07 2013 (r249982) +++ head/usr.sbin/syslogd/syslogd.c Sat Apr 27 13:26:35 2013 (r249983) @@ -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);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201304271326.r3RDQaFC099151>