Skip to content

Conversation

@UncleGrumpy
Copy link
Collaborator

These changes fix several open supervisor issues, as well as a few small bugs discovered in the supervisor and test_supervisor.erl.

  • Implements missing one_for_all restart strategy that is documented in the module.
  • Supervisors now obeys intensity and period options.
  • Children who fail to restart are retried until maximum restart intensity limit is reached
  • Fixes edge case bug when terminating as well as several typos.
  • Fixes some bugs in the test suite that left un-received messages in the test environment that would be received by additional tests added to the end of the lists in test_supervisor:/test/0.

Closes #1855
Closes #1915
Closed #1957

These changes are made under both the "Apache 2.0" and the "GNU Lesser General
Public License 2.1 or later" license terms (dual license).

SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later

Fix a missing edge case in loop_terminate/2 that could lead to loop_wait_termination/1 getting
stuck in an endless receive, preventing shutdown, if a later child crashes before loop_terminate/2
has itterated through the children to the now dead one.

Fixes a typo in the init funtion error return where the atom `mod` was returned rather than the
modules name (`Mod`).

Fixes a typo in child record `type`, adds missing parenthesis on the `child_type/0` type.

Signed-off-by: Winford <[email protected]>
Fixes some tests to catch the messages from child ping_pong_servers so they will not be received by
later tests. Changes the supervisor started in test_count_children to use a generic supervisor
without a child, rather than using the modules start_link which always starts a child
ping_pong_server that sends messages back to the test environment. Fixes the test_ping_ping final
`recieve` to match on a new `Pid4` (which would indicate a restart) rather than `Pid3` that the
monitor just caught the 'DOWN' message for.

Signed-off-by: Winford <[email protected]>
Adds support for handling restarts for the `one_for_all` strategy that was documented, but lacked
implimentation.

Closes atomvm#1855

Signed-off-by: Winford <[email protected]>
Adds support for honoring intensity and period supervisor options, allowing the prevention of
endless crash and restarts by misbehaving children.

Adds a test to ensure the settings work as expected on AtomVM and match OTP.

Closes atomvm#1915

Signed-off-by: Winford <[email protected]>
{error, no_supervisor2}
end,
ok =
case is_pid(ChildPid) of
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

believe you want ChildPid2 here

Copy link
Collaborator Author

@UncleGrumpy UncleGrumpy Nov 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I do! Thank you. I reworked this function a bit too, I decided it was a waist of CI time to wait 2000 ms for a child message if the supervisor failed to start 🤦 . I moved the check for a supervisor pid sooner and a fixed the variable name.

Fixes a function clause exception that would crash the supervisor if a child fails to restart by
matching the same behavior as OTP, and continue to try restarting the child until success, or
maximum `intensity` is reached within the allowed `period`.

Closed atomvm#1957

Signed-off-by: Winford <[email protected]>
@UncleGrumpy UncleGrumpy force-pushed the supervisor-one_for_all-main branch from e0f3afd to 7b2435d Compare November 4, 2025 18:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants