Me and my friend was trying to find a bug with our code for some time when we realised that this was the problem:
random_function(spawn_link(fun() -> worker(List, self(), Death) end));
This was the solution:
PID = self(),
random_function(spawn_link(fun() -> worker(List, PID, Death) end));
So my question is, why did it not work to just call the self()-function straight away like that? Is it because it's an anonymous function or is it some kind of special Erlang thing?