summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjh <jh@FreeBSD.org>2010-02-08 15:50:51 +0000
committerjh <jh@FreeBSD.org>2010-02-08 15:50:51 +0000
commit000376f24e6eac64c54f0693ac3b6730c0e446b9 (patch)
tree3cc3fcbf828c21d4d80f9b3deab3302e1d014f33
parent47a3486c10a17990d8bff6addf75c913dcbc745a (diff)
downloadFreeBSD-src-000376f24e6eac64c54f0693ac3b6730c0e446b9.zip
FreeBSD-src-000376f24e6eac64c54f0693ac3b6730c0e446b9.tar.gz
MFC r200752:
Avoid sharing the file descriptor of the output file with traced processes by setting the FD_CLOEXEC flag for the output file. PR: bin/140493
-rw-r--r--usr.bin/truss/main.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/usr.bin/truss/main.c b/usr.bin/truss/main.c
index d0dd073..586fcd6 100644
--- a/usr.bin/truss/main.c
+++ b/usr.bin/truss/main.c
@@ -239,6 +239,12 @@ main(int ac, char **av)
if ((trussinfo->outfile = fopen(fname, "w")) == NULL)
errx(1, "cannot open %s", fname);
}
+ /*
+ * Set FD_CLOEXEC, so that the output file is not shared with
+ * the traced process.
+ */
+ if (fcntl(fileno(trussinfo->outfile), F_SETFD, FD_CLOEXEC) == -1)
+ warn("fcntl()");
/*
* If truss starts the process itself, it will ignore some signals --
OpenPOWER on IntegriCloud