1
0
Fork 0
mirror of https://passt.top/passt synced 2025-07-26 03:27:59 +02:00

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: d0006fa784 ("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>
This commit is contained in:
Jon Maloy 2025-05-29 13:08:58 -04:00 committed by Stefano Brivio
commit 081df67d1f

3
conf.c
View file

@ -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,