summaryrefslogtreecommitdiffstats
path: root/lib/libkvm
diff options
context:
space:
mode:
authornectar <nectar@FreeBSD.org>2002-09-11 16:41:39 +0000
committernectar <nectar@FreeBSD.org>2002-09-11 16:41:39 +0000
commitc9164bea19b0a4c68e44ba6441e161696fc536f8 (patch)
treefb0e1627a81af9ff65b8f97a283a03bc8ae85c31 /lib/libkvm
parent927cfce43ea563f6042a80a8c89cb2357e15173e (diff)
downloadFreeBSD-src-c9164bea19b0a4c68e44ba6441e161696fc536f8.zip
FreeBSD-src-c9164bea19b0a4c68e44ba6441e161696fc536f8.tar.gz
In kvm_openfiles/kvm_open, mark the file descriptors as close-on-exec.
Applications can not do this themselves, as the descriptors are hidden behind the opaque `kvm_t' type.
Diffstat (limited to 'lib/libkvm')
-rw-r--r--lib/libkvm/kvm.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/libkvm/kvm.c b/lib/libkvm/kvm.c
index f0a6352..0802078 100644
--- a/lib/libkvm/kvm.c
+++ b/lib/libkvm/kvm.c
@@ -180,6 +180,10 @@ _kvm_open(kd, uf, mf, flag, errout)
_kvm_syserr(kd, kd->program, "%s", mf);
goto failed;
}
+ if (fcntl(kd->pmfd, F_SETFD, FD_CLOEXEC) < 0) {
+ _kvm_syserr(kd, kd->program, "%s", mf);
+ goto failed;
+ }
if (S_ISCHR(st.st_mode)) {
/*
* If this is a character special device, then check that
@@ -198,6 +202,10 @@ _kvm_open(kd, uf, mf, flag, errout)
_kvm_syserr(kd, kd->program, "%s", _PATH_KMEM);
goto failed;
}
+ if (fcntl(kd->vmfd, F_SETFD, FD_CLOEXEC) < 0) {
+ _kvm_syserr(kd, kd->program, "%s", _PATH_KMEM);
+ goto failed;
+ }
}
} else {
/*
@@ -209,6 +217,10 @@ _kvm_open(kd, uf, mf, flag, errout)
_kvm_syserr(kd, kd->program, "%s", uf);
goto failed;
}
+ if (fcntl(kd->nlfd, F_SETFD, FD_CLOEXEC) < 0) {
+ _kvm_syserr(kd, kd->program, "%s", uf);
+ goto failed;
+ }
if (_kvm_initvtop(kd) < 0)
goto failed;
}
OpenPOWER on IntegriCloud