init:stop () semantics

Ulf Wiger etxuwig@REDACTED
Mon Oct 14 11:42:10 CEST 2002

On Sun, 6 Oct 2002, Leonid Timochouk wrote:

>Hello Erlang users,
>In the documentation for the "init:stop()" function, it is
>said that "all applications are taken down smoothly".
>However, close analysis of the source code for this
>function (in OTP-R8B-2) suggests that it simply sends
>{'EXIT', kill} to all running processes except "heart" and
>"init" itself. Is it a smooth shutdown? Yet, it seems that
>the "stop()" call-back DOES get invoked for the running
>application -- how is it possible if all processes
>(including the application controller?) are brutally

It does look ominous, but if you study the function
init:shutdown_pids/3 --

shutdown_pids(Heart,BootPid,State) ->
    Timer = shutdown_timer(State#state.flags),
    catch shutdown(State#state.kernel,BootPid,Timer,State),
    kill_all_pids(Heart), % Even the shutdown timer.

-- you will see that the kill_all_pids/1 call is preceded by
a call to shutdown/4, which gracefully stops the kernel
application. This means shutting down the application
controller, among other things, and the application
controller will (in application_controller:terminate/2)
gracefully shut down all running applications before
terminating itself.

This (synchronous) procedure is guarded by a catch, and
after this, any processes that are left should of course be
mercilessly killed.

Ulf Wiger, Senior Specialist,
   / / /   Architecture & Design of Carrier-Class Software
  / / /    Strategic Product & System Management
 / / /     Ericsson Telecom AB, ATM Multiservice Networks

More information about the erlang-questions mailing list