File 1086-Apply-suggestions-from-code-review.patch of Package erlang
From 18cba2366be1abd901de0261b219497771f8e817 Mon Sep 17 00:00:00 2001
From: Jakub Witczak <u3s@users.noreply.github.com>
Date: Thu, 26 Sep 2024 09:03:38 +0200
Subject: [PATCH 2/2] Apply suggestions from code review
Co-authored-by: Rickard Green <rickard@erlang.org>
---
lib/stdlib/src/supervisor.erl | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/lib/stdlib/src/supervisor.erl b/lib/stdlib/src/supervisor.erl
index bb1b245634..2cfa8a5425 100644
--- a/lib/stdlib/src/supervisor.erl
+++ b/lib/stdlib/src/supervisor.erl
@@ -970,6 +970,13 @@ shutdown(#child{pid=Pid, shutdown=Time} = Child) ->
unlink_flush(Pid, noproc) ->
{links, Ls} = process_info(self(),links),
+ %% We know that the process has terminated. If we still have a link, we are
+ %% guaranteed to eventually receive the 'EXIT' message containing the
+ %% actual exit reason (or a 'noconnection' exit reason if the connection is
+ %% lost). If we do not have a link, the 'EXIT' message is already present
+ %% in the message queue unless the child process behaved badly (unlinked
+ %% itself from us). If it behaved badly, we may or may not receive an 'EXIT'
+ %% message.
Timeout = case lists:member(Pid, Ls) of
true -> infinity;
false -> 0
@@ -978,9 +985,10 @@ unlink_flush(Pid, noproc) ->
{'EXIT', Pid, ExitReason} ->
ExitReason
after Timeout ->
- naughty_child
+ child_process_unlinked
end;
unlink_flush(Pid, ExitReason) ->
+ %% Leave no 'EXIT' message from this process in the message queue.
unlink(Pid),
receive
{'EXIT', Pid, _} -> ok
--
2.43.0