xmake icon indicating copy to clipboard operation
xmake copied to clipboard

stdio重定向问题

Open waruqi opened this issue 2 years ago • 2 comments

Discussed in https://github.com/xmake-io/xmake/discussions/4527

Originally posted by Noroby December 21, 2023

add_rules("mode.debug", "mode.release")

target("main")
    set_kind("binary")
    add_files("src/*.cpp")
    set_toolchains("clang")
    set_languages("cxx20")
    on_run(function(target)
        os.execv(target:targetfile(), {}, {stdin = "input.txt"})
    end)

我执行execv时重定向了输入,但是运行程序时不会输出到终端?

waruqi avatar Dec 28 '23 01:12 waruqi

win 下才有的问题,这个地方导致 https://github.com/tboox/tbox/blob/059f19ed8f18cfcd59c1ca2f2aff3143157a0df4/src/tbox/platform/windows/process.c#L489

但是目前没有很好的办法解决,这块涉及很多细节东西 https://github.com/xmake-io/xmake/issues/3138#issuecomment-1338970250

waruqi avatar Dec 28 '23 01:12 waruqi

Bot detected the issue body's language is not English, translate it automatically.


Title: stdio redirection problem

Issues-translate-bot avatar Dec 28 '23 02:12 Issues-translate-bot