From patchwork Wed Dec 14 07:51:54 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ross Lagerwall X-Patchwork-Id: 9473779 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 4E8F760571 for ; Wed, 14 Dec 2016 07:54:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4340F2855E for ; Wed, 14 Dec 2016 07:54:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3724C286D5; Wed, 14 Dec 2016 07:54:50 +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 EBDCF2855E for ; Wed, 14 Dec 2016 07:54:49 +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 1cH4Mn-0001lD-MG; Wed, 14 Dec 2016 07:52:45 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cH4Ml-0001iS-RH for xen-devel@lists.xen.org; Wed, 14 Dec 2016 07:52:43 +0000 Received: from [85.158.143.35] by server-8.bemta-6.messagelabs.com id D4/D0-05787-B4AF0585; Wed, 14 Dec 2016 07:52:43 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmphkeJIrShJLcpLzFFi42JxWrrBXtfrV0C EwbMLchZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8b+i5EFxzkq+tZ/Z2xgvMTWxcjJISHgL3F2 w1UmEJtNwEDi1qXvzCC2iICsxOquOexdjFwczAIrGCXufd/JApIQFvCUeP+/G6yIRUBVYsHfl UA2BwcvUPzSS0uImXISN891gpVwCnhJND+6B7ZLCKjk/PI9rBC2msTb5WfARvIKCEqcnPkEzG YWkJA4+OIF8wRG3llIUrOQpBYwMq1i1ChOLSpLLdI1MtBLKspMzyjJTczM0TU0MNPLTS0uTkx PzUlMKtZLzs/dxAgMHQYg2MH4a1nAIUZJDiYlUV6uqwERQnxJ+SmVGYnFGfFFpTmpxYcYZTg4 lCR4TX4C5QSLUtNTK9Iyc4BBDJOW4OBREuG98gMozVtckJhbnJkOkTrFqCglzmsA0icAksgoz YNrg0XOJUZZKWFeRqBDhHgKUotyM0tQ5V8xinMwKgnzqoNM4cnMK4Gb/gpoMRPQYtEl/iCLSx IRUlINjCurGxsDMl1/O9tknn8Qb1vPojlhdebPiYv65Y+eqCySLdju/u1ZfkydwYLsRZOCxLo bRbesc5t41XbNm8UbjGJFHTudivbV3ZF9J8okzDDXe88UCX2fpDiBqzn3m2etUE3Y+2DNiUTm 7Pz0N90zL9Z0nOG9/vPeVe3aqn8tRbmOGixHNe+tUGIpzkg01GIuKk4EALRM3ceXAgAA X-Env-Sender: prvs=149da8861=ross.lagerwall@citrix.com X-Msg-Ref: server-7.tower-21.messagelabs.com!1481701959!48201096!3 X-Originating-IP: [66.165.176.63] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni42MyA9PiAzMDYwNDg=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 9.1.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 26899 invoked from network); 14 Dec 2016 07:52:42 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-7.tower-21.messagelabs.com with RC4-SHA encrypted SMTP; 14 Dec 2016 07:52:42 -0000 X-IronPort-AV: E=Sophos;i="5.33,345,1477958400"; d="scan'208";a="403521732" From: Ross Lagerwall To: Date: Wed, 14 Dec 2016 07:51:54 +0000 Message-ID: <1481701920-13758-3-git-send-email-ross.lagerwall@citrix.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1481701920-13758-1-git-send-email-ross.lagerwall@citrix.com> References: <1481701920-13758-1-git-send-email-ross.lagerwall@citrix.com> MIME-Version: 1.0 Cc: Ross Lagerwall , Ian Jackson , Wei Liu Subject: [Xen-devel] [PATCH v2 2/8] 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 stdout to unbuffered mode to fix this (stderr is always unbuffered by default). Signed-off-by: Ross Lagerwall Acked-by: Wei Liu --- tools/misc/xen-livepatch.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tools/misc/xen-livepatch.c b/tools/misc/xen-livepatch.c index f6c7c8a..56ae5aa 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,12 @@ int main(int argc, char *argv[]) { int i, j = 0, ret; + /* + * Set stdout to be unbuffered to avoid having to fflush when + * printing without a newline. + */ + setvbuf(stdout, NULL, _IONBF, 0); + if ( argc <= 1 ) { show_help();