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
This commit is contained in:
jh 2010-02-08 15:50:51 +00:00
parent 47a3486c10
commit 000376f24e

View File

@ -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 --