From owner-freebsd-bugs@FreeBSD.ORG Fri Nov 12 00:00:29 2010 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id F2BF8106566B for ; Fri, 12 Nov 2010 00:00:29 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id E1F838FC08 for ; Fri, 12 Nov 2010 00:00:29 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.4/8.14.4) with ESMTP id oAC00Tkl075324 for ; Fri, 12 Nov 2010 00:00:29 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.4/8.14.4/Submit) id oAC00Thv075296; Fri, 12 Nov 2010 00:00:29 GMT (envelope-from gnats) Date: Fri, 12 Nov 2010 00:00:29 GMT Message-Id: <201011120000.oAC00Thv075296@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org From: ashish@FreeBSD.org (Ashish SHUKLA) Cc: Subject: Re: bin/152151: truss causes programs to open fd number 2, clobbering random files X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Ashish SHUKLA List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 12 Nov 2010 00:00:30 -0000 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 -- --=-=-=--