From a16d9a4f16a9089f1cbafc287ec2c43aa9091717 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sat, 23 Apr 2022 09:56:24 -0700 Subject: subprocesses: flush *stdout*. * stream.c (open-subprocess, open_command, run): Flush the standard output stream before forking or spawning the child process. This gets tests/018/forkflush.tl to pass. --- stream.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/stream.c b/stream.c index 951815a3..ae80ef96 100644 --- a/stream.c +++ b/stream.c @@ -4432,6 +4432,8 @@ static val open_subprocess(val name, val mode_str, val args, val fun) if (!name && !fun) uw_throwf(error_s, lit("~a: program name and/or function required"), self, nao); + flush_stream(std_output); + fds_init(&sfds); fds_prepare(&sfds, fds_flags, self); @@ -4599,6 +4601,8 @@ val open_command(val path, val mode_str) FILE *f = 0; int fds_flags = (input ? FDS_IN : FDS_OUT) | FDS_ERR; + flush_stream(std_output); + fds_init(&sfds); uw_simple_catch_begin; @@ -4756,6 +4760,8 @@ static val run(val command, val args) args = default_null_arg(args); nargs = c_num(length(args), self) + 1; + flush_stream(std_output); + fds_init(&sfds); uw_simple_catch_begin; @@ -4832,6 +4838,8 @@ static val run(val name, val args) } argv[i] = 0; + flush_stream(std_output); + fds_init(&sfds); fds_prepare(&sfds, FDS_IN | FDS_OUT | FDS_ERR, self); -- cgit v1.2.3