From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=none (p=none dis=none) header.from=gibson.dropbear.id.au Authentication-Results: passt.top; dkim=pass (2048-bit key; secure) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.a=rsa-sha256 header.s=202504 header.b=N/lMzxHZ; dkim-atps=neutral Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id 902615A0280 for ; Fri, 30 May 2025 07:57:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202504; t=1748584631; bh=nNLV/VRQdtOjWfVNF3CKYPrUQ5Toz5tM40bGIjuGpcg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=N/lMzxHZFvJarKZs9WZJNcXfXgjEEPqmM6D4wHLZD7qcvBjZ/rSD41RkSIw1/+pmh 6BXiK5mJX12S50/A3Mc+4hLG1JEnf2wisVihIyrlicucdNNk0t7Cz7SouhEg3IYI/k XwZGiz39q+BBDlA/EFKl02nDt2alfX0ucd7GMZJ7Lgh4rUfmZ4srUuWLgwMbP7BLZU 4IPkyCX6sFKMU9GUIU+gQt1m257BQQ4sQATD/M3dasYEUTuQuJIgPOW1832xBzBUCu YN0Yx3OXDZ92P4k7FsR77i2ipCMMNykMyBpVDxu1ej+jQjqjtiuopIaZi8g/8hPw6O LlnRC+IKF6HDQ== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4b7svW3HSsz4x84; Fri, 30 May 2025 15:57:11 +1000 (AEST) Date: Fri, 30 May 2025 12:21:45 +1000 From: David Gibson To: Jon Maloy Subject: Re: conf: flush stdout before early exit Message-ID: References: <20250529170858.185281-1-jmaloy@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="EVncZVhVjJDpNp9f" Content-Disposition: inline In-Reply-To: <20250529170858.185281-1-jmaloy@redhat.com> Message-ID-Hash: WEJS3TDBPFZCMCVWUBTGH2TR7DGBRE7C X-Message-ID-Hash: WEJS3TDBPFZCMCVWUBTGH2TR7DGBRE7C X-MailFrom: dgibson@gandalf.ozlabs.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: sbrivio@redhat.com, dgibson@redhat.com, passt-dev@passt.top X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: --EVncZVhVjJDpNp9f Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, May 29, 2025 at 01:08:58PM -0400, Jon Maloy wrote: > Before doing an early exit any contents of stdout is normally flushed. > This doesn't happen when the output goes into a pipe and we return with > _exit(). We now add an explicit flush in such cases. Minor nitpicking on this description. AIUI * We'll *never* flush on exit with _exit(), not only when the output is a pipe * The reason we don't see the problem when stdout is a terminal is that in that case stdio flushes the buffer on each line > Fixes: d0006fa784a7 ("treewide: use _exit() over exit()") >=20 > Signed-off-by: Jon Maloy > --- > conf.c | 3 +++ > 1 file changed, 3 insertions(+) >=20 > diff --git a/conf.c b/conf.c > index a6d7e22..a1d55a3 100644 > --- a/conf.c > +++ b/conf.c > @@ -975,6 +975,7 @@ static void usage(const char *name, FILE *f, int stat= us) > " SPEC is as described for TCP above\n" > " default: none\n"); > =20 > + fflush(f); > _exit(status); > =20 > pasta_opts: > @@ -1029,6 +1030,7 @@ pasta_opts: > " --ns-mac-addr ADDR Set MAC address on tap interface\n" > " --no-splice Disable inbound socket splicing\n"); > =20 > + fflush(f); > _exit(status); > } > =20 > @@ -1594,6 +1596,7 @@ void conf(struct ctx *c, int argc, char **argv) > FPRINTF(stdout, > c->mode =3D=3D MODE_PASTA ? "pasta " : "passt "); > FPRINTF(stdout, VERSION_BLOB); > + fflush(stdout); > _exit(EXIT_SUCCESS); > case 15: > ret =3D snprintf(c->ip4.ifname_out, --=20 David Gibson (he or they) | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you, not the other way | around. http://www.ozlabs.org/~dgibson --EVncZVhVjJDpNp9f Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmg5FioACgkQzQJF27ox 2GcIlxAAq9xZyx0wmMo6ustsuF0MCSxUO+w4UzBL7Op5OT7Esq0BE/w9O8yo94Yv V9l1zJS0tCau7UZp3nQATiZ+66BAcSvdQFS8/MN2j0v2lNiDbwHa8dtK3w1T/Rt1 QuveaVBoQ9fGzFBq34WxPO56pcETbvlk3zN3189r1b3D+4ONmUmSlXCycT2V6cUT qODPo7ZQ7fEkjlYHK9cF2iXAIEyxkkqlPeFPabiti4qBSP6IJpMZl4W6dNNun1+5 LfngfDsLG+/50Gw7YTYH0ZN08QAHIA+W1XyGykj1nMmAwe1BDOhTJl6M7SECsyQP 11vP/RKwVk3dwQyhBwV6jep+cPOQvqDf8y6hFviXXYSFQnPnkgr6qqihwCYTL8dw gP/mlu9lPfwG/vWKa96ID+zyZDlCSJnGYd4aApcr6VLScvv849r+VHNJtctebPeo 8QFmH6UfWECTS3zw8uU+cOofxsW+pW6YG0SzscLzQbgjBkukhQNs1ztRXihJGSZX GUkRhB2ATbu5aHUtwBwb9LySGRU3hYBZKh520yVYcZeuoPVIoR/CEfv9EZdD8OWg b84JHspkFz2KJL0dQVMsAGnYuh8s4qWkYX8+7mNM5BTBfF8tlV6ewwyiFtHToZRa Q9zwIfs05kjHMcKNWqTB6XgBzJXKXYm0dan2SH3f5ae4ttvvMGM= =L6Tm -----END PGP SIGNATURE----- --EVncZVhVjJDpNp9f--