From patchwork Mon Dec 12 16:18:05 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ross Lagerwall X-Patchwork-Id: 9470917 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8F3FC60573 for ; Mon, 12 Dec 2016 16:24:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 87182284D4 for ; Mon, 12 Dec 2016 16:24:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7A8E4284D9; Mon, 12 Dec 2016 16:24:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 6ABCF284D4 for ; Mon, 12 Dec 2016 16:24:14 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cGTMf-0002El-Mf; Mon, 12 Dec 2016 16:22:09 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cGTMe-0002D6-Il for xen-devel@lists.xen.org; Mon, 12 Dec 2016 16:22:08 +0000 Received: from [85.158.143.35] by server-9.bemta-6.messagelabs.com id 9C/C7-28694-0BECE485; Mon, 12 Dec 2016 16:22:08 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmphkeJIrShJLcpLzFFi42JxWrohUnf9Ob8 IgxvXTC2WfFzM4sDocXT3b6YAxijWzLyk/IoE1owZD1+zF5znqDiz9ABTA+M1ti5GTg4JAX+J T2e+s4DYbAIGErcufWcGsUUEZCVWd81h72Lk4mAWWMEoce/7TqAiDg5hAU+JfVPqQWpYBFQll k85xQQS5gUKN7XnQYyUk7h5rhNsDKeAl8TtLe3sILYQUMmyzk+sELaaxNvlZ8DW8goISpyc+Q TMZhaQkDj44gXzBEbeWUhSs5CkFjAyrWLUKE4tKkst0jUy1UsqykzPKMlNzMzRNTQw08tNLS5 OTE/NSUwq1kvOz93ECAwdBiDYwbhqQeAhRkkOJiVR3i8H/CKE+JLyUyozEosz4otKc1KLDzHK cHAoSfAePQuUEyxKTU+tSMvMAQYxTFqCg0dJhFcUGMhCvMUFibnFmekQqVOMilLivMdB+gRAE hmleXBtsMi5xCgrJczLCHSIEE9BalFuZgmq/CtGcQ5GJWHe2yBTeDLzSuCmvwJazAS0+Pk+b5 DFJYkIKakGxmV277WrdBin3BAVqupoy3up5bpWcVom14vPa4TbWdj7XfcJfZoQVjgtSHNpQcX 2mtdv64OW6DasOcYdpn1EIlT01dqVgVpWmdm7u6rr50TnbhH4ISiXp7NbW/bWnoR3Pcuu8Tx+ su31obOHZ+z51Ga48dKqdzu+Zd6Y4MS6UCI9RdctlslGQ4mlOCPRUIu5qDgRAOnHi2qXAgAA X-Env-Sender: prvs=147044df7=ross.lagerwall@citrix.com X-Msg-Ref: server-4.tower-21.messagelabs.com!1481559724!41703460!3 X-Originating-IP: [66.165.176.89] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni44OSA9PiAyMDMwMDc=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 9.1.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 32548 invoked from network); 12 Dec 2016 16:22:07 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-4.tower-21.messagelabs.com with RC4-SHA encrypted SMTP; 12 Dec 2016 16:22:07 -0000 X-IronPort-AV: E=Sophos;i="5.33,337,1477958400"; d="scan'208";a="394308074" From: Ross Lagerwall To: Date: Mon, 12 Dec 2016 16:18:05 +0000 Message-ID: <1481559490-13844-3-git-send-email-ross.lagerwall@citrix.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1481559490-13844-1-git-send-email-ross.lagerwall@citrix.com> References: <1481559490-13844-1-git-send-email-ross.lagerwall@citrix.com> MIME-Version: 1.0 Cc: Ross Lagerwall , Ian Jackson , Wei Liu Subject: [Xen-devel] [PATCH v1 2/7] tools/livepatch: Set stdout and stderr unbuffered X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Using both stdout and stderr interleaved without newlines can result in strange output when using line buffered mode (e.g. a terminal) or when fully buffered (e.g. redirected to a file). Set both to unbuffered mode to fix this. Signed-off-by: Ross Lagerwall --- tools/misc/xen-livepatch.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tools/misc/xen-livepatch.c b/tools/misc/xen-livepatch.c index f6c7c8a..2f6721b 100644 --- a/tools/misc/xen-livepatch.c +++ b/tools/misc/xen-livepatch.c @@ -330,7 +330,6 @@ int action_func(int argc, char *argv[], unsigned int idx) } printf("."); - fflush(stdout); usleep(DELAY); } while ( ++retry < RETRIES ); @@ -416,6 +415,13 @@ int main(int argc, char *argv[]) { int i, j = 0, ret; + /* + * Set stdout and stderr to be unbuffered to avoid having to fflush + * when printing without a newline. + */ + setvbuf(stdout, NULL, _IONBF, 0); + setvbuf(stderr, NULL, _IONBF, 0); + if ( argc <= 1 ) { show_help();