Erlang / Erlang Basics Interview questions
What happens when a linked process crashes?
When a linked process terminates abnormally, the BEAM sends an exit signal carrying the exit reason to every process it's linked to. What happens next depends on whether the receiving process is trapping exits.
process_flag(trap_exit, true), Pid = spawn_link(fun() -> exit(boom) end), receive {'EXIT', Pid, Reason} -> io:format("child died: ~p~n", [Reason]) end.
By default, a process receiving a non-normal exit signal also terminates with that same reason, propagating
the failure outward — which is exactly how a crash in one worker can cascade up to a supervisor. If the
receiving process has called process_flag(trap_exit, true), the exit signal instead arrives as an
ordinary {'EXIT', Pid, Reason} message it can pattern-match on and react to, which is precisely
how supervisors detect child crashes without being killed by them.
Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!
Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.
Invest now!!! Get Free equity stock (US, UK only)!
Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.
The Robinhood app makes it easy to trade stocks, crypto and more.
Webull! Receive free stock by signing up using the link: Webull signup.
More Related questions...
