@@ -174,13 +174,27 @@ init(internal, [Shell, Options], State = #state{ dumb = Dumb }) ->
174174
175175-spec whereis_shell () -> undefined | pid ().
176176whereis_shell () ->
177- case node (group_leader ()) of
177+ GroupLeaderPid = group_leader (),
178+ case node (GroupLeaderPid ) of
178179 Node when Node =:= node () ->
179- case user_drv :whereis_group () of
180- undefined -> undefined ;
181- GroupPid ->
182- {dictionary , Dict } = erlang :process_info (GroupPid , dictionary ),
183- proplists :get_value (shell , Dict )
180+ maybe
181+ {dictionary , GroupLeaderDict } ?= erlang :process_info (GroupLeaderPid , dictionary ),
182+ {shell , GroupLeaderShellPid } ?= lists :keyfind (shell , 1 , GroupLeaderDict ),
183+ true ?= is_pid (GroupLeaderShellPid ),
184+ GroupLeaderShellPid
185+ else
186+ _ ->
187+ maybe
188+ GroupPid ?= user_drv :whereis_group (),
189+ true ?= is_pid (GroupPid ),
190+ {dictionary , GroupDict } ?= erlang :process_info (GroupPid , dictionary ),
191+ {shell , GroupShellPid } ?= lists :keyfind (shell , 1 , GroupDict ),
192+ true ?= is_pid (GroupShellPid ),
193+ GroupShellPid
194+ else
195+ _ ->
196+ undefined
197+ end
184198 end ;
185199 OtherNode ->
186200 erpc :call (OtherNode , group , whereis_shell , [])
0 commit comments