Skip to content

Commit 6b3c835

Browse files
committed
Fix a crash when gpio:close/0 is called but server was not running
Signed-off-by: Paul Guyot <pguyot@kallisys.net>
1 parent 82b4e7c commit 6b3c835

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

libs/eavmlib/src/gpio.erl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,12 @@ close(GPIO) ->
146146
%%-----------------------------------------------------------------------------
147147
-spec stop() -> ok | {error, Reason :: atom()} | error.
148148
stop() ->
149-
close(whereis(gpio)).
149+
case whereis(gpio) of
150+
undefined ->
151+
ok;
152+
Port when is_port(Port) ->
153+
close(Port)
154+
end.
150155

151156
%%-----------------------------------------------------------------------------
152157
%% @param GPIO pid that was returned from gpio:start/0

0 commit comments

Comments
 (0)