
[;1m  exit(Reason)[0m

  Raises an exception of class [;;4mexit[0m with exit reason [;;4mReason[0m.

  As evaluating this function causes an exception to be raised, it
  has no return value.

  The intent of the exception class [;;4mexit[0m is that the current
  process should be stopped (for example when a message telling a
  process to stop is received).

  This function differ from [;;4merror/1,2,3[0m by causing an exception of
  a different class and by having a reason that does not include the
  list of functions from the call stack.

  See the guide about errors and error handling for additional
  information.

  Example:

    > exit(foobar).
    ** exception exit: foobar
    > catch exit(foobar).
    {'EXIT',foobar}

  [;;4mNote[0m

    If a process calls [;;4mexit(kill)[0m and does not catch the
    exception, it will terminate with exit reason [;;4mkill[0m and also
    emit exit signals with exit reason [;;4mkill[0m (not [;;4mkilled[0m) to
    all linked processes. Such exit signals with exit reason [;;4mkill[0m
    can be trapped by the linked processes. Note that this means
    that signals with exit reason [;;4mkill[0m behave differently
    depending on how they are sent because the signal will be
    untrappable if a process sends such a signal to another
    process with [;;4merlang:exit/2[0m.

[;1m  exit(Pid, Reason)[0m

  Sends an exit signal with exit reason [;;4mReason[0m to the process or
  port identified by [;;4mPid[0m.

  The following behavior applies if [;;4mReason[0m is any term, except [;;4m[0m
  [;;4mnormal[0m or [;;4mkill[0m, and [;;4mP[0m is the process or port identified by [;;4m[0m
  [;;4mPid[0m:

   • If [;;4mP[0m is not trapping exits, [;;4mP[0m exits with exit reason [;;4m[0m
     [;;4mReason[0m.

   • If [;;4mP[0m is trapping exits, the exit signal is transformed
     into a message [;;4m{'EXIT', From, Reason}[0m, where [;;4mFrom[0m is the
     process identifier of the process that sent the exit signal,
     and delivered to the message queue of [;;4mP[0m.

  The following behavior applies if [;;4mReason[0m is the term [;;4mnormal[0m
  and [;;4mPid[0m is the identifier of a process [;;4mP[0m which is not the same
  as the process that invoked [;;4merlang:exit(Pid, normal)[0m (the
  behavior when a process sends a signal with the [;;4mnormal[0m reason to
  itself is described in the warning):

   • If [;;4mP[0m is trapping exits, the exit signal is transformed
     into a message [;;4m{'EXIT', From, normal}[0m, where [;;4mFrom[0m is the
     process identifier of the process that sent the exit signal,
     and delivered to [;;4mP[0m's message queue.

   • The signal has no effect if [;;4mP[0m is not trapping exits.

  If [;;4mReason[0m is the atom [;;4mkill[0m, that is, if [;;4mexit(Pid, kill)[0m is
  called, an untrappable exit signal is sent to the process that is
  identified by [;;4mPid[0m, which unconditionally exits with exit reason [;;4m[0m
  [;;4mkilled[0m. The exit reason is changed from [;;4mkill[0m to [;;4mkilled[0m to
  hint to linked processes that the killed process got killed by a
  call to [;;4mexit(Pid, kill)[0m.

  [;;4mNote[0m

    The functions [;;4merlang:exit/1[0m and [;;4merlang:exit/2[0m are named
    similarly but provide very different functionalities. The [;;4m[0m
    [;;4merlang:exit/1[0m function should be used when the intent is to
    stop the current process while [;;4merlang:exit/2[0m should be used
    when the intent is to send an exit signal to another process.
    Note also that [;;4merlang:exit/1[0m raises an exception that can be
    caught while [;;4merlang:exit/2[0m does not cause any exception to
    be raised.

  [;;4mWarning[0m

    The only scenario that has not been covered by the description
    above is when a process [;;4mP[0m sends an exit signal with reason [;;4m[0m
    [;;4mnormal[0m to itself, that is [;;4merlang:exit(self(), normal)[0m. The
    behavior in this scenario is as follows:

     • If [;;4mP[0m is trapping exits, the exit signal is transformed
       into a message [;;4m{'EXIT', From, normal}[0m, where [;;4mFrom[0m is [;;4m[0m
       [;;4mP[0m's process identifier, and delivered to [;;4mP[0m's message
       queue.

     • [;;4mP[0m exits with reason [;;4mnormal[0m if [;;4mP[0m is not trapping
       exits. Note that the behavior described above is
       different from when a process sends an exit signal with
       reason [;;4mnormal[0m to another process. This is arguably
       strange but this behavior is kept for backward
       compatibility reasons.

  [;;4mNote[0m

    For some important information about distributed signals, see
    the Blocking Signaling Over Distribution section in the 
    Processes chapter of the Erlang Reference Manual.
