mosic

mosic

Why do processes started with :simple_one_for_one strategy appear to have :undefined id?

I’ve been wondering about this, why doesn’t Supervisor.which_children/1 (and underlying :supervisor.which_children/1 of course) return the names of the child processes? Is it an inherent limitation of BEAM or is it done for other reasons (performance)?

I know that the registered name of the process can be retrieved by getting the information about that pid:

iex(1)> [{_, pid, _, _}] = Supervisor.which_children MyApp.Simple.Supervisor
[{:undefined, #PID<0.823.0>, :worker, [MyApp.Simple.Worker]}]
iex(2)> Process.info(pid)[:registered_name]
:my_named_process

Marked As Solved

Qqwy

Qqwy

TypeCheck Core Team

It is because in the case of a simple_one_for_one, the child specification will not list what processes will be started, but a template that will be used as blueprint for all started children of this Supervisor.

There can potentially multiple child processes be started from the same blueprint (and often this is the case), which means that returning an ID would be confusing (as it would not uniquely identify that specific process).

Also Liked

mosic

mosic

Thanks @Qqwy, your reply prompted me to read the documentation again, this time more carefully.

I have figured what was the problem - I misunderstood what the Supervisor.Spec.child_id in Supervisor.which_children/1 represents, for some reason I thought that it was the registered name of the child process, not the template used for spawning the process.

Where Next?

Popular in Questions Top

bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
makeitrein
Hey all, just started picking up Elixir last week and am writing a scraper as a learning project. Baby step #1 is extracting the number ...
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
chewm
Hi guys, nice to meet you to the whole forum, I’m new here, I’m trying to configure visual studio code for elixir, right now the intellis...
New
hpopp
To simplify some tasks at work, I wrote and published this package yesterday. It’s a simple macro that enables Access behaviour on struct...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New

Other popular topics Top

William
I would like to know that is there any online source for learning Phoenix Framework for building E-Commerce Store? Any advantage on build...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
AstonJ
You’re a programmer, so you don’t need spoon feeding with the conventional drivel about “this is an integer.” No. You need to know what’s...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
lk-geimfari
What is most correct way to open, read and parse JSON file with poison? For example if we have example.json file in root of some projec...
New
danschultzer
None of the current solutions worked well for me, so I went ahead and built a user management system from scratch. This project took far...
548 27727 240
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? https://hexdocs.pm/ecto/Ecto.Repo.h...
New
chrisalley
ExUnit now has describe blocks which is a welcome addition coming from RSpec. In the docs, it states that nested hierarchies of describe ...
New
TunkShif
This post is an instruction guide to help you setup your Neovim for Elixir development from scratch. It includes general information on h...
273 38985 115
New

We're in Beta

About us Mission Statement