Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 12 Nov 2009 17:30:04 GMT
From:      Erik <erik@datahack.se>
To:        freebsd-bugs@FreeBSD.org
Subject:   Re: bin/140493: truss(1) log file descriptor shared with traced program
Message-ID:  <200911121730.nACHU4st047401@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/140493; it has been noted by GNATS.

From: Erik <erik@datahack.se>
To: bug-followup@FreeBSD.org, erik@datahack.se
Cc:  
Subject: Re: bin/140493: truss(1) log file descriptor shared with traced program
Date: Thu, 12 Nov 2009 18:06:41 +0100

 This is a multi-part message in MIME format.
 --------------020501070508070709040003
 Content-Type: text/plain; charset=ISO-8859-1; format=flowed
 Content-Transfer-Encoding: 7bit
 
 Not reporting issues 10pm...we could of course set FD_CLOEXEC on the fd. 
 See proposed patched.
 
 --------------020501070508070709040003
 Content-Type: text/x-patch;
  name="truss-cloexec.patch"
 Content-Transfer-Encoding: 7bit
 Content-Disposition: inline;
  filename="truss-cloexec.patch"
 
 --- main.c-original	2009-11-12 18:52:25.000000000 +0000
 +++ main.c	2009-11-12 18:59:42.000000000 +0000
 @@ -227,6 +227,17 @@
  	if (fname != NULL) { /* Use output file */
  		if ((trussinfo->outfile = fopen(fname, "w")) == NULL)
  			errx(1, "cannot open %s", fname);
 +
 +		/*
 +		 * Do not share the file descriptor with the traced
 +		 * process executed with execvp().
 +		 */
 +		int fd = fileno(trussinfo->outfile);
 +		int flags = fcntl(fd, F_GETFD, 0);
 +		if (flags != -1)
 +		{
 +			fcntl(fd, F_SETFD, flags | FD_CLOEXEC);
 +		}
  	}
  
  	/*
 
 --------------020501070508070709040003--



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