Date: Sat, 16 Apr 2016 13:10:32 +0000 (UTC) From: Baptiste Daroussin <bapt@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r298114 - head/usr.sbin/inetd Message-ID: <201604161310.u3GDAWXJ080742@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: bapt Date: Sat Apr 16 13:10:31 2016 New Revision: 298114 URL: https://svnweb.freebsd.org/changeset/base/298114 Log: Use the SOCK_CLOEXEC flags in the socket(2) 'type' attribute instead of calling fcntl(2) MFC after: 1 week Modified: head/usr.sbin/inetd/inetd.c Modified: head/usr.sbin/inetd/inetd.c ============================================================================== --- head/usr.sbin/inetd/inetd.c Sat Apr 16 12:49:26 2016 (r298113) +++ head/usr.sbin/inetd/inetd.c Sat Apr 16 13:10:31 2016 (r298114) @@ -1251,7 +1251,9 @@ setup(struct servtab *sep) { int on = 1; - if ((sep->se_fd = socket(sep->se_family, sep->se_socktype, 0)) < 0) { + /* Set all listening sockets to close-on-exec. */ + if ((sep->se_fd = socket(sep->se_family, + sep->se_socktype | SOCK_CLOEXEC, 0)) < 0) { if (debug) warn("socket failed on %s/%s", sep->se_service, sep->se_proto); @@ -1259,13 +1261,6 @@ setup(struct servtab *sep) sep->se_service, sep->se_proto); return; } - /* Set all listening sockets to close-on-exec. */ - if (fcntl(sep->se_fd, F_SETFD, FD_CLOEXEC) < 0) { - syslog(LOG_ERR, "%s/%s: fcntl (F_SETFD, FD_CLOEXEC): %m", - sep->se_service, sep->se_proto); - close(sep->se_fd); - return; - } #define turnon(fd, opt) \ setsockopt(fd, SOL_SOCKET, opt, (char *)&on, sizeof (on)) if (strcmp(sep->se_proto, "tcp") == 0 && (options & SO_DEBUG) &&
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201604161310.u3GDAWXJ080742>