From owner-svn-src-stable-8@FreeBSD.ORG Thu Nov 18 19:06:57 2010 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2CB16106566B; Thu, 18 Nov 2010 19:06:57 +0000 (UTC) (envelope-from jh@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 1E10E8FC08; Thu, 18 Nov 2010 19:06:57 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id oAIJ6v3j042133; Thu, 18 Nov 2010 19:06:57 GMT (envelope-from jh@svn.freebsd.org) Received: (from jh@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oAIJ6uNW042131; Thu, 18 Nov 2010 19:06:56 GMT (envelope-from jh@svn.freebsd.org) Message-Id: <201011181906.oAIJ6uNW042131@svn.freebsd.org> From: Jaakko Heinonen Date: Thu, 18 Nov 2010 19:06:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r215466 - stable/8/usr.bin/truss X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 18 Nov 2010 19:06:57 -0000 Author: jh Date: Thu Nov 18 19:06:56 2010 New Revision: 215466 URL: http://svn.freebsd.org/changeset/base/215466 Log: MFC r215235: Set FD_CLOEXEC for the output file only when the file has been specified with the -o option. Setting the flag for stderr (the default) could cause the traced process to redirect stderr to a random file. PR: bin/152151 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 Thu Nov 18 18:49:04 2010 (r215465) +++ stable/8/usr.bin/truss/main.c Thu Nov 18 19:06:56 2010 (r215466) @@ -238,13 +238,14 @@ main(int ac, char **av) 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. + */ + 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 --