Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 20 Dec 2009 11:00:53 +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: r200752 - head/usr.bin/truss
Message-ID:  <200912201100.nBKB0rFr062212@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jh
Date: Sun Dec 20 11:00:53 2009
New Revision: 200752
URL: http://svn.freebsd.org/changeset/base/200752

Log:
  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
  Submitted by:	Erik Lax
  OK'ed by:	delphij
  Approved by:	trasz (mentor)

Modified:
  head/usr.bin/truss/main.c

Modified: head/usr.bin/truss/main.c
==============================================================================
--- head/usr.bin/truss/main.c	Sun Dec 20 10:58:34 2009	(r200751)
+++ head/usr.bin/truss/main.c	Sun Dec 20 11:00:53 2009	(r200752)
@@ -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?200912201100.nBKB0rFr062212>