From nobody Wed May 15 22:24:41 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1646833472; cv=none; d=zohomail.com; s=zohoarc; b=VTGIkb6OHVbBygjJRRIEc7FgO9plHyFKyFjDL7emg4dziDRkDWYEZ8zKCoR96p0T5Q7FdUpdfc093Cg3ZQhBjKyyTGoFQK1CLP1GTA1BxVFEl6dWEDMVvSZfbn4BRHwhfLlXngGAHGdg73eqTbVueh+hW6ytRimSJCacYG/wP3k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1646833472; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=lyHcjLlW5usBN9otRE5dDy+25cmn3JjRXMcR3tg4q1I=; b=GCJMj7hc4kn4+U2+/G0O7Cp+0AEHboL4Zn9g3xhDXSYQve2Xz7lCO6vJX/7Z0B3SfdB10LaBea5Y8WLJC8KQ2AACUiQO+BW9k8ppYRlRihuprar/zJyRSdNNNrDP7GW4EjSblDuwO7yVTvKCY70yKc2mS6D9KZgy9RTGGJIMgi0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1646833472811579.8903301953931; Wed, 9 Mar 2022 05:44:32 -0800 (PST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-363-RW7fckv3P9uxSOeEdeyQnA-1; Wed, 09 Mar 2022 08:44:30 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A1DB0899EE3; Wed, 9 Mar 2022 13:44:28 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 007C9C080AD; Wed, 9 Mar 2022 13:44:28 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 9A8BC1953566; Wed, 9 Mar 2022 13:44:27 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 0B85E194F4AE for ; Wed, 9 Mar 2022 13:11:34 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id A162484629; Wed, 9 Mar 2022 13:11:33 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2B8C984603 for ; Wed, 9 Mar 2022 13:11:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646833471; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=lyHcjLlW5usBN9otRE5dDy+25cmn3JjRXMcR3tg4q1I=; b=dZj8Yth2bagmk+4C5AVgluQiz0w+YJfguZojmujIqEOdaBqvOQoWoqZXz0czWJGW+xWh/7 J7Yyf5+MrJFB/kfVuhoHQW863eybcvS2U3Fi8y4krwMZU6hGea8wCJjzNLAbiXjUVIwzFf YcLg9MWhEFtznJ1tpvfnW9/rEEVNsLI= X-MC-Unique: RW7fckv3P9uxSOeEdeyQnA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH] virsh: fflush(stdout) after fputs() Date: Wed, 9 Mar 2022 14:11:19 +0100 Message-Id: <940d88fa327c796c0a9955974bc2b1e5fa40e9f3.1646831479.git.mprivozn@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1646833474923100001 Content-Type: text/plain; charset="utf-8" We are not guaranteed that the string we are printing onto stdout contains '\n' and thus that the stdout is flushed. In fact, I've met this problem when virsh asked me whether I want to edit the domain XML again (vshAskReedit()) but the prompt wasn't displayed (as it does not contain a newline character) and virsh just sat there waiting for my input, I sat there waiting for virsh's output. Flush stdout after all fputs()-s which do not flush stdout. Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- tools/vsh.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/vsh.c b/tools/vsh.c index bbde594967..499794c8fc 100644 --- a/tools/vsh.c +++ b/tools/vsh.c @@ -1863,6 +1863,7 @@ vshDebug(vshControl *ctl, int level, const char *form= at, ...) str =3D g_strdup_vprintf(format, ap); va_end(ap); fputs(str, stdout); + fflush(stdout); } =20 void @@ -1878,6 +1879,7 @@ vshPrintExtra(vshControl *ctl, const char *format, ..= .) str =3D g_strdup_vprintf(format, ap); va_end(ap); fputs(str, stdout); + fflush(stdout); } =20 =20 @@ -1891,6 +1893,7 @@ vshPrint(vshControl *ctl G_GNUC_UNUSED, const char *f= ormat, ...) str =3D g_strdup_vprintf(format, ap); va_end(ap); fputs(str, stdout); + fflush(stdout); } =20 =20 @@ -2938,6 +2941,7 @@ vshReadline(vshControl *ctl G_GNUC_UNUSED, int len; =20 fputs(prompt, stdout); + fflush(stdout); r =3D fgets(line, sizeof(line), stdin); if (r =3D=3D NULL) return NULL; /* EOF */ =20 --=20 2.34.1