summaryrefslogtreecommitdiffstats
path: root/usr.bin/truss/main.c
diff options
context:
space:
mode:
authorjh <jh@FreeBSD.org>2009-12-20 11:00:53 +0000
committerjh <jh@FreeBSD.org>2009-12-20 11:00:53 +0000
commit05e68d005a67f1a5977aeeeea80c91c219a3ad09 (patch)
tree2680180ea8126d97ac5fc545b4147fe67d5e5ace /usr.bin/truss/main.c
parentd51d2e56fc222c467689c165f203863b77393a6b (diff)
downloadFreeBSD-src-05e68d005a67f1a5977aeeeea80c91c219a3ad09.zip
FreeBSD-src-05e68d005a67f1a5977aeeeea80c91c219a3ad09.tar.gz
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 Submitted by: Erik Lax OK'ed by: delphij Approved by: trasz (mentor)
Diffstat (limited to 'usr.bin/truss/main.c')
-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