summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2017-10-25 21:03:38 +0800
committerruki <[email protected]>2017-10-25 00:21:52 +0800
commit1d8d394240647e595e923d08c9f3cd1ec1881d8c (patch)
treeb6d9d5ccc92e177a7a00064d3d2347e0fd7fa8c2
parent0144b2a95a7aeccb1802843ab597a2c2f30fdb4a (diff)
fix redirect io order
-rw-r--r--xmake/core/sandbox/modules/os.lua14
1 files changed, 14 insertions, 0 deletions
diff --git a/xmake/core/sandbox/modules/os.lua b/xmake/core/sandbox/modules/os.lua
index e761140a8..933f08e5b 100644
--- a/xmake/core/sandbox/modules/os.lua
+++ b/xmake/core/sandbox/modules/os.lua
@@ -355,6 +355,20 @@ function sandbox_os.execv(program, argv)
-- make program
program = vformat(program)
+ -- flush io buffer first for fixing redirect io output order
+ --
+ -- .e.g
+ --
+ -- xmake run > /tmp/a
+ -- print("xxx1")
+ -- os.exec("echo xxx2")
+ --
+ -- cat /tmp/a
+ -- xxx2
+ -- xxx1
+ --
+ io.flush()
+
-- run it
local ok = os.execv(program, argv)
if ok ~= 0 then