mirror of
https://github.com/uselessd/alcove.git
synced 2026-04-15 01:04:41 +00:00
badpid: use error exception instead of exit
A badpid exception should be an error:
OSPid = try alcove:getpid(Drv, [1,2,3])
catch
error:badpid -> handle_error(...)
end.
This commit is contained in:
@@ -194,34 +194,34 @@ call_reply(Drv, Pids, false, Timeout) ->
|
||||
{alcove_ctl, Drv, Pids, fdctl_closed} ->
|
||||
ok;
|
||||
{alcove_ctl, Drv, _Pids, badpid} ->
|
||||
exit(badpid);
|
||||
erlang:error(badpid);
|
||||
{alcove_call, Drv, Pids, Event} ->
|
||||
Event
|
||||
after
|
||||
Timeout ->
|
||||
exit(timeout)
|
||||
erlang:error(timeout)
|
||||
end;
|
||||
call_reply(Drv, Pids, true, Timeout) ->
|
||||
receive
|
||||
{alcove_ctl, Drv, Pids, fdctl_closed} ->
|
||||
call_reply(Drv, Pids, true, Timeout);
|
||||
{alcove_event, Drv, Pids, {termsig,_} = Event} ->
|
||||
exit(Event);
|
||||
erlang:error(Event);
|
||||
{alcove_event, Drv, Pids, {exit_status,_} = Event} ->
|
||||
exit(Event);
|
||||
erlang:error(Event);
|
||||
{alcove_ctl, Drv, _Pids, badpid} ->
|
||||
exit(badpid);
|
||||
erlang:error(badpid);
|
||||
{alcove_call, Drv, Pids, Event} ->
|
||||
Event
|
||||
after
|
||||
Timeout ->
|
||||
exit(timeout)
|
||||
erlang:error(timeout)
|
||||
end.
|
||||
|
||||
reply(Drv, Pids, Type, Timeout) ->
|
||||
receive
|
||||
{alcove_ctl, Drv, _Pids, badpid} ->
|
||||
exit(badpid);
|
||||
erlang:error(badpid);
|
||||
{Type, Drv, Pids, Event} ->
|
||||
Event
|
||||
after
|
||||
|
||||
@@ -73,7 +73,7 @@ kill(#state{pid = Drv}) ->
|
||||
|
||||
[
|
||||
?_assertEqual(Pid, Reply0),
|
||||
?_assertEqual({'EXIT',{termsig,sigsys}}, Reply1),
|
||||
?_assertMatch({'EXIT',{{termsig,sigsys},_}}, Reply1),
|
||||
?_assertEqual({error, esrch}, Reply2)
|
||||
].
|
||||
|
||||
|
||||
@@ -433,9 +433,9 @@ badpid(#state{pid = Drv}) ->
|
||||
"/bin/sh", ["/bin/sh", "-c", "echo > /dev/null"])),
|
||||
|
||||
[
|
||||
?_assertEqual({'EXIT',badpid}, Reply0),
|
||||
?_assertEqual({'EXIT',badpid}, Reply1),
|
||||
?_assertEqual({'EXIT',badpid}, Reply2)
|
||||
?_assertMatch({'EXIT',{badpid,_}}, Reply0),
|
||||
?_assertMatch({'EXIT',{badpid,_}}, Reply1),
|
||||
?_assertMatch({'EXIT',{badpid,_}}, Reply2)
|
||||
].
|
||||
|
||||
signal(#state{pid = Drv}) ->
|
||||
|
||||
Reference in New Issue
Block a user