Skip to content

Commit 9fba161

Browse files
committed
Allow group_leader() to define shell:whereis()
1 parent 4ca5fcb commit 9fba161

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

lib/kernel/src/group.erl

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -174,13 +174,26 @@ init(internal, [Shell, Options], State = #state{ dumb = Dumb }) ->
174174

175175
-spec whereis_shell() -> undefined | pid().
176176
whereis_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+
Key = {dictionary, shell},
181+
maybe
182+
{Key, GroupLeaderShellPid} ?= erlang:process_info(GroupLeaderPid, Key),
183+
true ?= is_pid(GroupLeaderShellPid),
184+
GroupLeaderShellPid
185+
else
186+
_ ->
187+
maybe
188+
GroupPid ?= user_drv:whereis_group(),
189+
true ?= is_pid(GroupPid),
190+
{Key, GroupShellPid} ?= erlang:process_info(GroupPid, Key),
191+
true ?= is_pid(GroupShellPid),
192+
GroupShellPid
193+
else
194+
_ ->
195+
undefined
196+
end
184197
end;
185198
OtherNode ->
186199
erpc:call(OtherNode, group, whereis_shell, [])

0 commit comments

Comments
 (0)