Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 12 Nov 2010 00:00:29 GMT
From:      ashish@FreeBSD.org (Ashish SHUKLA)
To:        freebsd-bugs@FreeBSD.org
Subject:   Re: bin/152151: truss causes programs to open fd number 2, clobbering random files
Message-ID:  <201011120000.oAC00Thv075296@freefall.freebsd.org>

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

From: ashish@FreeBSD.org (Ashish SHUKLA)
To: bug-followup@FreeBSD.org,brong@fastmail.fm
Cc:  
Subject: Re: bin/152151: truss causes programs to open fd number 2, clobbering random files
Date: Fri, 12 Nov 2010 05:27:00 +0530

 --=-=-=
 Content-Type: text/plain
 
 Hi,
 
 Attached diff (based on the hints mentioned by Bron) fixes the problem for me.
 
 HTH
 -- 
 Ashish SHUKLA      | GPG: F682 CDCC 39DC 0FEA E116  20B6 C746 CFA9 E74F A4B0
 freebsd.org!ashish | http://people.freebsd.org/~ashish/
 
 Avoid Success At All Costs !!
 
 --=-=-=
 Content-Type: text/plain
 Content-Disposition: attachment; filename=main.c.diff
 Content-Description: diff
 
 --- main.c~	2010-11-11 23:46:13.000000000 +0000
 +++ main.c	2010-11-11 23:55:11.000000000 +0000
 @@ -238,13 +238,14 @@
  	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.
 +		 */
 +		else 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?201011120000.oAC00Thv075296>