public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
From: Jon Maloy <jmaloy@redhat.com>
To: sbrivio@redhat.com, dgibson@redhat.com, jmaloy@redhat.com,
	passt-dev@passt.top
Subject: conf: flush stdout before early exit
Date: Thu, 29 May 2025 13:08:58 -0400	[thread overview]
Message-ID: <20250529170858.185281-1-jmaloy@redhat.com> (raw)

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.

Fixes: d0006fa784a7 ("treewide: use _exit() over exit()")

Signed-off-by: Jon Maloy <jmaloy@redhat.com>
---
 conf.c | 3 +++
 1 file changed, 3 insertions(+)

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 status)
 		"    SPEC is as described for TCP above\n"
 		"    default: none\n");
 
+	fflush(f);
 	_exit(status);
 
 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");
 
+	fflush(f);
 	_exit(status);
 }
 
@@ -1594,6 +1596,7 @@ void conf(struct ctx *c, int argc, char **argv)
 			FPRINTF(stdout,
 				c->mode == MODE_PASTA ? "pasta " : "passt ");
 			FPRINTF(stdout, VERSION_BLOB);
+			fflush(stdout);
 			_exit(EXIT_SUCCESS);
 		case 15:
 			ret = snprintf(c->ip4.ifname_out,
-- 
@@ -975,6 +975,7 @@ static void usage(const char *name, FILE *f, int status)
 		"    SPEC is as described for TCP above\n"
 		"    default: none\n");
 
+	fflush(f);
 	_exit(status);
 
 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");
 
+	fflush(f);
 	_exit(status);
 }
 
@@ -1594,6 +1596,7 @@ void conf(struct ctx *c, int argc, char **argv)
 			FPRINTF(stdout,
 				c->mode == MODE_PASTA ? "pasta " : "passt ");
 			FPRINTF(stdout, VERSION_BLOB);
+			fflush(stdout);
 			_exit(EXIT_SUCCESS);
 		case 15:
 			ret = snprintf(c->ip4.ifname_out,
-- 
2.48.1


             reply	other threads:[~2025-05-29 17:09 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-29 17:08 Jon Maloy [this message]
2025-05-30  2:21 ` conf: flush stdout before early exit David Gibson
2025-05-30  8:08 ` Stefano Brivio
2025-05-30 10:00 ` Paul Holzinger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250529170858.185281-1-jmaloy@redhat.com \
    --to=jmaloy@redhat.com \
    --cc=dgibson@redhat.com \
    --cc=passt-dev@passt.top \
    --cc=sbrivio@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://passt.top/passt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).