Skip to content
This repository has been archived by the owner on May 12, 2018. It is now read-only.

Commit

Permalink
Merge pull request #1 from lrascao/fix/remove-async-ref
Browse files Browse the repository at this point in the history
Remove async ref when exit signaled
lrascao committed Mar 12, 2016
2 parents 3409aa7 + 3b7fd49 commit ffef7d0
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/retest_sh.erl
Original file line number Diff line number Diff line change
@@ -83,7 +83,7 @@ run(Cmd, Opts) ->
stop(Ref) ->
#sh { pid = Pid, port = Port } = erlang:get(Ref),
_ = os:cmd(?FMT("kill ~s", [Pid])),
exit_loop(Port).
exit_loop(Ref, Port).

stop_all() ->
_ = [ {ok, _} = stop(Ref) || {Ref, Sh} <- erlang:get(),
@@ -115,13 +115,14 @@ read_pid(Port) ->
{error, {stopped, Rc}}
end.

exit_loop(Port) ->
exit_loop(Ref, Port) ->
receive
{Port, {data, {_, Line}}} ->
?DEBUG("~p: ~s\n", [erlang:get(retest_module), Line]),
exit_loop(Port);
exit_loop(Ref, Port);

{Port, {exit_status, Rc}} ->
erlang:erase(Ref),
{ok, Rc}
end.

0 comments on commit ffef7d0

Please sign in to comment.