Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 8 Feb 2010 15:50:51 +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-8@freebsd.org
Subject:   svn commit: r203667 - stable/8/usr.bin/truss
Message-ID:  <201002081550.o18FopI0087061@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jh
Date: Mon Feb  8 15:50:51 2010
New Revision: 203667
URL: http://svn.freebsd.org/changeset/base/203667

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

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

Modified: stable/8/usr.bin/truss/main.c
==============================================================================
--- stable/8/usr.bin/truss/main.c	Mon Feb  8 15:48:18 2010	(r203666)
+++ stable/8/usr.bin/truss/main.c	Mon Feb  8 15:50:51 2010	(r203667)
@@ -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 --



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201002081550.o18FopI0087061>