[Bug 206128] vmstat -z is truncated when stdout is not terminal

bugzilla-noreply at freebsd.org bugzilla-noreply at freebsd.org
Sat May 28 06:42:58 UTC 2016


https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=206128

--- Comment #11 from Phil Shafer <phil at freebsd.org> ---
Was finally able to reproduce this and have a fix.  I was using the wrong value
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 = 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 = 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

-- 
You are receiving this mail because:
You are the assignee for the bug.


More information about the freebsd-bugs mailing list