File 0125-code_SUITE-Ensure-started-processes-are-terminated.patch of Package erlang

From c9a62f30571ec29747a70247bb403a8608a0915e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= <bjorn@erlang.org>
Date: Tue, 14 Mar 2023 13:55:51 +0100
Subject: [PATCH 1/2] code_SUITE: Ensure started processes are terminated

Use `spawn_link/2` instead of `spawn/2` to ensure that processes
are terminated if the test cases fails.
---
 lib/kernel/test/code_SUITE.erl | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/lib/kernel/test/code_SUITE.erl b/lib/kernel/test/code_SUITE.erl
index e996d43d59..8eadcf9cb3 100644
--- a/lib/kernel/test/code_SUITE.erl
+++ b/lib/kernel/test/code_SUITE.erl
@@ -1748,9 +1748,9 @@ on_load_self_call(_Config) ->
     ok.
 
 on_load_do_load(Mod, Code) ->
-    spawn(fun() ->
-		  {module,Mod} = code:load_binary(Mod, "", Code)
-	  end),
+    spawn_link(fun() ->
+                       {module,Mod} = code:load_binary(Mod, "", Code)
+               end),
     receive
 	Any -> Any
     end.
@@ -1841,9 +1841,9 @@ on_load_deleted(_Config) ->
 			    "  receive _ -> ok end.\n"]),
 		 merl:print(Tree),
 		 {ok,Mod,Code} = merl:compile(Tree),
-		 spawn(fun() ->
-			       {module,Mod} = code:load_binary(Mod, "", Code)
-		       end),
+		 spawn_link(fun() ->
+                                    {module,Mod} = code:load_binary(Mod, "", Code)
+                            end),
 		 receive after 1 -> ok end,
 		 {module,OtherMod} = code:load_binary(OtherMod, "",
 						      OtherCode),
@@ -1866,10 +1866,10 @@ delete_before_reload(Mod, Reload) ->
     {ok,Mod,Code1} = merl:compile(Tree1),
 
     Self = self(),
-    spawn(fun() ->
-		  {module,Mod} = code:load_binary(Mod, "", Code1),
-		  Mod:f(Self)
-	  end),
+    spawn_link(fun() ->
+                       {module,Mod} = code:load_binary(Mod, "", Code1),
+                       Mod:f(Self)
+               end),
     receive started -> ok end,
 
     true = code:delete(Mod),
-- 
2.35.3

openSUSE Build Service is sponsored by