os: flush stdout and stderr before calling _wsystem (on windows), as the MSDN doc advices (#20034)

This commit is contained in:
gym603 2023-11-30 01:25:41 +08:00 committed by GitHub
parent 74c59abf4e
commit dc3ea0f87f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -400,6 +400,8 @@ pub fn system(cmd string) int {
// overcome bug in system & _wsystem (cmd) when first char is quote `"` // overcome bug in system & _wsystem (cmd) when first char is quote `"`
wcmd := if cmd.len > 1 && cmd[0] == `"` && cmd[1] != `"` { '"${cmd}"' } else { cmd } wcmd := if cmd.len > 1 && cmd[0] == `"` && cmd[1] != `"` { '"${cmd}"' } else { cmd }
unsafe { unsafe {
C.fflush(C.stdout)
C.fflush(C.stderr)
ret = C._wsystem(wcmd.to_wide()) ret = C._wsystem(wcmd.to_wide())
} }
} $else { } $else {