From owner-svn-src-all@FreeBSD.ORG Tue Nov 1 09:28:48 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3372E106564A; Tue, 1 Nov 2011 09:28:48 +0000 (UTC) (envelope-from fabient@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 2360E8FC0A; Tue, 1 Nov 2011 09:28:48 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id pA19SmvN058459; Tue, 1 Nov 2011 09:28:48 GMT (envelope-from fabient@svn.freebsd.org) Received: (from fabient@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id pA19SmSP058457; Tue, 1 Nov 2011 09:28:48 GMT (envelope-from fabient@svn.freebsd.org) Message-Id: <201111010928.pA19SmSP058457@svn.freebsd.org> From: Fabien Thomas Date: Tue, 1 Nov 2011 09:28:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r226986 - head/usr.sbin/pmcstat X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Nov 2011 09:28:48 -0000 Author: fabient Date: Tue Nov 1 09:28:47 2011 New Revision: 226986 URL: http://svn.freebsd.org/changeset/base/226986 Log: Two bugs fixed: - Do not close stdout or stderr when redirecting to file. - Correctly handle error code to detect when no buffer available. MFC after: 1 month Modified: head/usr.sbin/pmcstat/pmcstat.c Modified: head/usr.sbin/pmcstat/pmcstat.c ============================================================================== --- head/usr.sbin/pmcstat/pmcstat.c Tue Nov 1 08:57:49 2011 (r226985) +++ head/usr.sbin/pmcstat/pmcstat.c Tue Nov 1 09:28:47 2011 (r226986) @@ -796,7 +796,9 @@ main(int argc, char **argv) break; case 'o': /* outputfile */ - if (args.pa_printfile != NULL) + if (args.pa_printfile != NULL && + args.pa_printfile != stdout && + args.pa_printfile != stderr) (void) fclose(args.pa_printfile); if ((args.pa_printfile = fopen(optarg, "w")) == NULL) errx(EX_OSERR, "ERROR: cannot open \"%s\" for " @@ -1394,7 +1396,7 @@ main(int argc, char **argv) case EVFILT_TIMER: /* print out counting PMCs */ if ((args.pa_flags & FLAG_DO_TOP) && - pmc_flush_logfile() != ENOBUFS) + pmc_flush_logfile() == 0) do_read = 1; do_print = 1; break;