aboutgitcodebugslistschat
diff options
context:
space:
mode:
authorJon Maloy <jmaloy@redhat.com>2025-05-29 13:08:58 -0400
committerStefano Brivio <sbrivio@redhat.com>2025-06-06 10:46:40 +0200
commit081df67d1fb28bf7a98f98c6c3417ec1d45ce6d7 (patch)
treec25a3b65e007c51be91c175db28b7cf2bd871e67
parentbcb559600545498ae7598617ef82d2810937132c (diff)
downloadpasst-081df67d1fb28bf7a98f98c6c3417ec1d45ce6d7.tar
passt-081df67d1fb28bf7a98f98c6c3417ec1d45ce6d7.tar.gz
passt-081df67d1fb28bf7a98f98c6c3417ec1d45ce6d7.tar.bz2
passt-081df67d1fb28bf7a98f98c6c3417ec1d45ce6d7.tar.lz
passt-081df67d1fb28bf7a98f98c6c3417ec1d45ce6d7.tar.xz
passt-081df67d1fb28bf7a98f98c6c3417ec1d45ce6d7.tar.zst
passt-081df67d1fb28bf7a98f98c6c3417ec1d45ce6d7.zip
conf: flush stdout before early exit
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. Reported-by: John Radley <jradxl2@gmail.com> Fixes: d0006fa784a7 ("treewide: use _exit() over exit()") Signed-off-by: Jon Maloy <jmaloy@redhat.com> Reviewed-by: Paul Holzinger <pholzing@redhat.com> [sbrivio: cast fflush() calls to void to dodge clang-tidy warning] Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
-rw-r--r--conf.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/conf.c b/conf.c
index f4c8ca2..36845e2 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");
+ (void)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");
+ (void)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);
+ (void)fflush(stdout);
_exit(EXIT_SUCCESS);
case 15:
ret = snprintf(c->ip4.ifname_out,