Date: Sat, 13 Nov 2010 09:28:49 +0000 (UTC) From: Jaakko Heinonen <jh@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r215235 - head/usr.bin/truss Message-ID: <201011130928.oAD9Snfx042314@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: jh Date: Sat Nov 13 09:28:49 2010 New Revision: 215235 URL: http://svn.freebsd.org/changeset/base/215235 Log: 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 Modified: head/usr.bin/truss/main.c Modified: head/usr.bin/truss/main.c ============================================================================== --- head/usr.bin/truss/main.c Sat Nov 13 08:58:36 2010 (r215234) +++ head/usr.bin/truss/main.c Sat Nov 13 09:28:49 2010 (r215235) @@ -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 --
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201011130928.oAD9Snfx042314>