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
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()")
Signed-off-by: Jon Maloy
--- 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,
-- 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
Thanks for the patch! Cc'ing with full quote for review Paul as author
of d0006fa784a7, and John as reporter of the issue.
On Thu, 29 May 2025 13:08:58 -0400
Jon Maloy
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
--- 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,
-- Stefano
Hi, On 29/05/2025 19:08, 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.
Fixes: d0006fa784a7 ("treewide: use _exit() over exit()")
Signed-off-by: Jon Maloy
Reviewed-by: Paul Holzinger
--- 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,
-- Paul Holzinger
participants (4)
-
David Gibson
-
Jon Maloy
-
Paul Holzinger
-
Stefano Brivio