From owner-freebsd-bugs@freebsd.org Sat May 28 06:42:58 2016 Return-Path: Delivered-To: freebsd-bugs@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 42980B4D231 for ; Sat, 28 May 2016 06:42:58 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2001:1900:2254:206a::16:76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 0FAD212D1 for ; Sat, 28 May 2016 06:42:58 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from bugs.freebsd.org ([127.0.1.118]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id u4S6gvxK048654 for ; Sat, 28 May 2016 06:42:57 GMT (envelope-from bugzilla-noreply@freebsd.org) From: bugzilla-noreply@freebsd.org To: freebsd-bugs@FreeBSD.org Subject: [Bug 206128] vmstat -z is truncated when stdout is not terminal Date: Sat, 28 May 2016 06:42:57 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: bin X-Bugzilla-Version: 11.0-CURRENT X-Bugzilla-Keywords: regression X-Bugzilla-Severity: Affects Only Me X-Bugzilla-Who: phil@freebsd.org X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: freebsd-bugs@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 28 May 2016 06:42:58 -0000 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D206128 --- Comment #11 from Phil Shafer --- Was finally able to reproduce this and have a fix. I was using the wrong v= alue when checking for available buffer space: diff --git a/libxo/libxo.c b/libxo/libxo.c index 9df67de..7a714b1 100644 --- a/libxo/libxo.c +++ b/libxo/libxo.c @@ -2816,7 +2816,7 @@ xo_format_string (xo_handle_t *xop, xo_buffer_t *xbp, xo_xff_flags_t flags, * but if we did the work ourselves, then we need to do it. */ int delta =3D xfp->xf_width[XF_WIDTH_MIN] - cols; - if (!xo_buf_has_room(xbp, delta)) + if (!xo_buf_has_room(xbp, xfp->xf_width[XF_WIDTH_MIN])) goto bail; /* In addition, I'm adding a high-water mark that will trigger a flush: @@ -6128,6 +6128,12 @@ xo_do_emit_fields (xo_handle_t *xop, xo_field_info_t *fields, XOIF_CLEAR(xop, XOIF_REORDER); + /* + * If we've got enough data, flush it. + */ + if (xo_buf_offset(&xop->xo_data) > XO_BUF_HIGH_WATER) + flush =3D 1; + /* If we don't have an anchor, write the text out */ if (flush && !XOIF_ISSET(xop, XOIF_ANCHOR)) { if (xo_write(xop) < 0) I'll roll a new version of libxo tomorrow. Apologies for taking so long with this, but it was mostly just an issue of reproducing it. I wasn't seeing enough churn in my "vmstat -z" value to trigger the issue, so I munged one of the regression tests to help. Thanks, Phil --=20 You are receiving this mail because: You are the assignee for the bug.=