0
我有一個簡單的端口應用程序(字面上是Erlang -- Ports documentation的示例)和一個控制其使用的GenServer。端口信息返回到意外進程
GenServer可以與C應用程序通信,但它不會收到響應,iex或其主管會這樣做。如果我從iex調用flush
,我會看到預期的消息。
如果我創建一個單獨的模塊並從中產生接收循環,它仍然不會收到端口響應消息。
我有一種感覺,我不正確地打開端口,但不能證明它。有什麼明顯的我搞砸了嗎?
port = Port.open({:spawn, "./extprg"}, [{:packet, 2}, :exit_status])
collect = fun() -> collect_results(port) end
spawn(collect)
def collect_results(port) do
receive do
{^port, {:data, data}} ->
#never gets called despite matching messages in flush
{^port, {:exit_status, status}} ->
#never gets called...
{:increment, value} ->
Port.command(port, [1, value])
collect_results(port)
end
end