FD_CLOEXEC
fcntl(fd, F_SETFD, FD_CLOEXEC);
if (fcntl(ttyfd, F_SETFD, FD_CLOEXEC) < 0) {
fcntl(i, F_SETFD, FD_CLOEXEC);
if (fcntl(sock, F_SETFD, FD_CLOEXEC) == -1 ||
(void)fcntl(rfd, F_SETFD, FD_CLOEXEC);
(void)fcntl(wfd, F_SETFD, FD_CLOEXEC);
(void)fcntl(efd, F_SETFD, FD_CLOEXEC);
if (fcntl(x, F_SETFD, FD_CLOEXEC) == -1) \
(void)fcntl(sock, F_SETFD, FD_CLOEXEC);
fcntl(sock_out, F_SETFD, FD_CLOEXEC);
fcntl(sock_in, F_SETFD, FD_CLOEXEC);
if (fcntl(listen_sock, F_SETFD, FD_CLOEXEC) == -1) {
flags |= FD_CLOEXEC;
fdflags = ((flags & O_CLOEXEC) != 0 ? FD_CLOEXEC : 0) |
if (fdflags == -1 || ((fdflags & FD_CLOEXEC) == 0 &&
_fcntl(fd, F_SETFD, fdflags | FD_CLOEXEC) == -1) ||
_fcntl(__sfileno(iop), F_SETFD, FD_CLOEXEC);
if (_fcntl(fd, F_SETFD, FD_CLOEXEC) != 0 ||
((tmp = _fcntl(fd, F_GETFD, 0)) & FD_CLOEXEC) == 0)
_fcntl(fd, F_SETFD, tmp | FD_CLOEXEC); /* silently ignore err */
(fdflags & FD_CLOEXEC) == 0)
(void)_fcntl(fileno(fp), F_SETFD, fdflags | FD_CLOEXEC);
if (_fcntl(daemon_fd, F_SETFD, flags & FD_CLOEXEC) == -1) {
if (_fcntl(fd, F_SETFD, flags & FD_CLOEXEC) == -1) {
if (flags != -1 && (flags & FD_CLOEXEC) == 0)
(void)fcntl(sd, F_SETFD, flags | FD_CLOEXEC);
if (fcntl(kd->pmfd, F_SETFD, FD_CLOEXEC) < 0) {
if (fcntl(kd->vmfd, F_SETFD, FD_CLOEXEC) < 0) {
if (fcntl(kd->nlfd, F_SETFD, FD_CLOEXEC) < 0) {
error = __sys_fcntl(fd, F_SETFD, FD_CLOEXEC);
fcntl(fd_in, F_SETFD, fflags & ~FD_CLOEXEC);
dat->fc_fdflags = ((tmp & UF_EXCLOSE) ? FD_CLOEXEC : 0) |
((dat->fc_fdflags & FD_CLOEXEC) ? UF_EXCLOSE : 0) |
if ((nflags & ~(FD_CLOEXEC | FD_CLOFORK)) != 0) {
((nflags & FD_CLOEXEC) != 0 ? DUP_CLOEXEC : 0) |
if (fcntl(fd2, F_GETFD) != FD_CLOEXEC)
if (fcntl(fd2, F_GETFD) != FD_CLOEXEC)
.clo_flags = FD_CLOEXEC,
.clo_flags = FD_CLOEXEC | FD_CLOFORK,
.clo_flags = FD_CLOEXEC,
.clo_flags = FD_CLOEXEC | FD_CLOFORK,
.clo_flags = FD_CLOEXEC,
.clo_flags = FD_CLOEXEC | FD_CLOFORK,
.clo_flags = FD_CLOEXEC,
.clo_flags = FD_CLOEXEC | FD_CLOFORK,
.clo_flags = FD_CLOEXEC,
.clo_flags = FD_CLOEXEC | FD_CLOFORK,
.clo_flags = FD_CLOEXEC,
.clo_flags = FD_CLOEXEC | FD_CLOFORK,
.clo_flags = FD_CLOEXEC,
.clo_flags = FD_CLOEXEC | FD_CLOFORK,
.clo_flags = FD_CLOEXEC,
.clo_flags = FD_CLOEXEC | FD_CLOFORK,
.clo_flags = FD_CLOEXEC,
.clo_flags = FD_CLOEXEC | FD_CLOFORK,
.clo_flags = FD_CLOEXEC,
.clo_flags = FD_CLOEXEC | FD_CLOFORK,
.clo_flags = FD_CLOEXEC,
.clo_flags = FD_CLOEXEC | FD_CLOFORK,
.clo_flags = FD_CLOEXEC,
.clo_flags = FD_CLOEXEC | FD_CLOFORK,
if ((oclo_rtdata[i].crt_flags & FD_CLOEXEC) != 0)
if ((c->clo_flags & FD_CLOEXEC) != 0)
oclo_setfd_common(c, FD_CLOEXEC);
oclo_setfd_common(c, FD_CLOFORK | FD_CLOEXEC);
oclo_fdup_common(c, FD_CLOEXEC, F_DUPFD_CLOEXEC);
oclo_fdup_common(c, FD_CLOEXEC, F_DUP2FD_CLOEXEC);
oclo_fdup_common(c, FD_CLOEXEC, F_DUP3FD);
oclo_fdup_common(c, FD_CLOEXEC | FD_CLOFORK, F_DUP3FD);
if ((targ_flags & FD_CLOEXEC) != 0)
oclo_dup_common(c, FD_CLOEXEC, true);
oclo_dup_common(c, FD_CLOEXEC | FD_CLOFORK, true);
if ((c->clo_flags & FD_CLOEXEC) != 0)
if ((c->clo_flags & FD_CLOEXEC) != 0)
if ((c->clo_flags & FD_CLOEXEC) != 0)
if ((targ_flags & FD_CLOEXEC) != 0)
oclo_accept_common(c, FD_CLOEXEC, true);
oclo_accept_common(c, FD_CLOEXEC | FD_CLOFORK, true);
if ((c->clo_flags & FD_CLOEXEC) != 0)
if ((targ_flags & FD_CLOEXEC) != 0)
oclo_rights_common(c, FD_CLOEXEC);
oclo_rights_common(c, FD_CLOEXEC | FD_CLOFORK);
.clo_flags = FD_CLOEXEC,
.clo_flags = FD_CLOEXEC | FD_CLOFORK,
.clo_flags = FD_CLOEXEC,
.clo_flags = FD_CLOEXEC | FD_CLOFORK,
.clo_flags = FD_CLOEXEC,
.clo_flags = FD_CLOEXEC | FD_CLOFORK,
.clo_flags = FD_CLOEXEC,
.clo_flags = FD_CLOEXEC | FD_CLOFORK,
.clo_flags = FD_CLOEXEC,
.clo_flags = FD_CLOEXEC | FD_CLOFORK,
.clo_flags = FD_CLOEXEC,
.clo_flags = FD_CLOEXEC | FD_CLOFORK,
.clo_flags = FD_CLOEXEC,
.clo_flags = FD_CLOEXEC | FD_CLOFORK,
.clo_flags = FD_CLOEXEC,
.clo_flags = FD_CLOEXEC | FD_CLOFORK,
.clo_flags = FD_CLOEXEC,
.clo_flags = FD_CLOEXEC | FD_CLOFORK,
.clo_flags = FD_CLOEXEC,
.clo_flags = FD_CLOEXEC | FD_CLOFORK,
.clo_flags = FD_CLOEXEC,
.clo_flags = FD_CLOEXEC | FD_CLOFORK,
.clo_flags = FD_CLOEXEC,
.clo_flags = FD_CLOEXEC | FD_CLOFORK,
.clo_flags = FD_CLOEXEC,
.clo_flags = FD_CLOEXEC | FD_CLOFORK,
.clo_flags = FD_CLOEXEC,
.clo_flags = FD_CLOEXEC | FD_CLOFORK,
.clo_flags = FD_CLOEXEC,
.clo_flags = FD_CLOEXEC | FD_CLOFORK,
(FD_CLOEXEC | FD_CLOFORK) + 1)) {
(val < 0 || val > (FD_CLOEXEC | FD_CLOFORK))) {
bool fail = (exp_flags & FD_CLOEXEC) != 0;
fcntl(fd, F_SETFD, FD_CLOEXEC);
if (fcntl(sep->se_fd, F_SETFD, FD_CLOEXEC) < 0) {