我正在使用以下脚本运行erlang进程
#!/bin/sh
stty -f /dev/tty icanon raw
erl -pa ./ -run thing start -run init -noshell
stty echo echok icanon -raw我的Erlang进程:
-module(thing).
-compile(export_all).
process(<<27>>) ->
io:fwrite("Ch: ~w", [<<27>>]),
exit(normal);
process(Ch) ->
io:fwrite("Ch: ~w", [Ch]),
get_char().
get_char() ->
Ch = io:get_chars("p: ", 1),
process(Ch).
start() ->
io:setopts([{binary, true}]),
get_char().当我运行./invoke.sh时,我按键并看到字符按预期打印。当我按下escape时,shell窗口停止响应(我必须从终端关闭窗口)。这一切为什么要发生?
发布于 2017-04-06 00:50:58
当您调用仅终止erlang进程的exit/1时,这并不会停止erlang运行时系统(beam)。由于您在没有shell情况下运行,因此您会得到窗口没有响应的行为。如果你从你的任务管理器或者通过pkill杀掉了beam进程,你会得到你的命令行。一个简单的解决方法是用halt() see doc替换exit(normal)
https://stackoverflow.com/questions/42792422
复制相似问题