Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 18 Nov 2010 19:08:57 +0000 (UTC)
From:      Jaakko Heinonen <jh@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org
Subject:   svn commit: r215467 - stable/7/usr.bin/truss
Message-ID:  <201011181908.oAIJ8v8g042213@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jh
Date: Thu Nov 18 19:08:56 2010
New Revision: 215467
URL: http://svn.freebsd.org/changeset/base/215467

Log:
  MFC r215235:
  
  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

Modified:
  stable/7/usr.bin/truss/main.c
Directory Properties:
  stable/7/usr.bin/truss/   (props changed)

Modified: stable/7/usr.bin/truss/main.c
==============================================================================
--- stable/7/usr.bin/truss/main.c	Thu Nov 18 19:06:56 2010	(r215466)
+++ stable/7/usr.bin/truss/main.c	Thu Nov 18 19:08:56 2010	(r215467)
@@ -230,13 +230,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?201011181908.oAIJ8v8g042213>