diff options
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/inetd/inetd.c | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/usr.sbin/inetd/inetd.c b/usr.sbin/inetd/inetd.c index f2d504f..752a7a4 100644 --- a/usr.sbin/inetd/inetd.c +++ b/usr.sbin/inetd/inetd.c @@ -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) && |