开发者

spawn get_line for stdin and have it work?

开发者 https://www.devze.com 2023-02-14 11:31 出处:网络
how do I get this to work spawn(fun() -> io:get_line(\"Prompt>\") end). to where it would work as if it didn\'t开发者_如何学JAVA have the spawn. I tried standard_io and group_leader() but doe

how do I get this to work

spawn(fun() -> io:get_line("Prompt>") end).

to where it would work as if it didn't开发者_如何学JAVA have the spawn. I tried standard_io and group_leader() but doesn't make difference.


Try

spawn(fun() -> timer:sleep(100),io:get_line("Prompt>") end).

What you see is a race condition between shell and your spawn/1. Generally when doing anything with io:get_line I would advice using 'erl -noshell -s Mod Fun' to start the program as that makes this issue go away.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号