DynamicSupervisor - why does it ignore exit signals from non-child processes?

DynamicSupervisor traps exit signals and handles ones coming from its children:

However, it also implicitly ignores exit signals from non-child processes: elixir/lib/elixir/lib/dynamic_supervisor.ex at 427d21e410d1846c232d0a0b0e87cce629884dfa · elixir-lang/elixir · GitHub

Does anyone know - is it an intentional design decision?

I’m trying to link it to a process that’s not its direct parent/child, so it would exit when the other process exits, but of course at the moment it doesn’t work. I don’t care so much about my use-case per-se (I can figure out a solution), but I’m in general wondering if there’s a good reason for how DynamicSupervisor is implemented - i.e. maybe I’m doing something that goes against first principles?

It’s not exclusive to DynamicSupervisor it seems - also happens with Supervisor.

If that process is not direct parent/child then why it is linked to supervisor?

Ultimately I’m interested in shutting down the supervisor when that process exits. And vice versa - I want the process to shut down when the supervisor exits.

Establishing a link between them would’ve been the easiest option.

Make that proces being supervised by that supervisor instead, and then make it :significant (though I do not know if DynamicSupervisor supports that, but if that process is known to be there, then why it is part of DynamicSupervisor?).

2 Likes