Set FD_CLOEXEC for the output file only when the file has been specified
with the -o option. Setting the flag for stderr (the default) could cause the traced process to redirect stderr to a random file. PR: bin/152151 Submitted by: ashish MFC after: 5 days
This commit is contained in:
parent
231c8b7113
commit
e04c378683
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=215235
@ -241,13 +241,14 @@ main(int ac, char **av)
|
||||
if (fname != NULL) { /* Use output file */
|
||||
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()");
|
||||
}
|
||||
/*
|
||||
* 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 --
|
||||
|
Loading…
Reference in New Issue
Block a user