svn commit: r200752 - head/usr.bin/truss
Jaakko Heinonen
jh at FreeBSD.org
Sun Dec 20 11:00:53 UTC 2009
Author: jh
Date: Sun Dec 20 11:00:53 2009
New Revision: 200752
URL: http://svn.freebsd.org/changeset/base/200752
Log:
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)
Modified:
head/usr.bin/truss/main.c
Modified: head/usr.bin/truss/main.c
==============================================================================
--- head/usr.bin/truss/main.c Sun Dec 20 10:58:34 2009 (r200751)
+++ head/usr.bin/truss/main.c Sun Dec 20 11:00:53 2009 (r200752)
@@ -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 --
More information about the svn-src-head
mailing list