%% %CopyrightBegin%
%%
%% SPDX-License-Identifier: Apache-2.0
%%
%% Copyright Ericsson AB 2021-2025. All Rights Reserved.
%%
%% %CopyrightEnd%

[;1m  link(PidOrPort)[0m

  Sets up and activates a link between the calling process and
  another process or a port identified by [;;4mPidOrPort[0m.

  We will from here on call the identified process or port linkee.
  If the linkee is a port, it must reside on the same node as the
  caller.

  If one of the participants of a link terminates, it will send an
  exit signal to the other participant. The exit signal will contain
  the exit reason of the terminated participant. Other cases when
  exit signals are triggered due to a link are when no linkee exist ([;;4m[0m
  [;;4mnoproc[0m exit reason) and when the connection between linked
  processes on different nodes is lost or cannot be established ([;;4m[0m
  [;;4mnoconnection[0m exit reason).

  An existing link can be removed by calling [;;4munlink/1[0m. For more
  information on links and exit signals due to links, see the 
  Processes chapter in the Erlang Reference Manual:

   • Links

   • Sending Exit Signals

   • Receiving Exit Signals

  For historical reasons, [;;4mlink/1[0m has a strange semi-synchronous
  behavior when it is "cheap" to check if the linkee exists or not,
  and the caller does not trap exits. If the above is true and the
  linkee does not exist, [;;4mlink/1[0m will raise a [;;4mnoproc[0m error 
  exception. The expected behavior would instead have been that [;;4m[0m
  [;;4mlink/1[0m returned [;;4mtrue[0m, and the caller later was sent an exit
  signal with [;;4mnoproc[0m exit reason, but this is unfortunately not
  the case. The [;;4mnoproc[0m exception is not to be confused with an
  exit signal with exit reason [;;4mnoproc[0m. Currently it is "cheap" to
  check if the linkee exists when it is supposed to reside on the
  same node as the calling process.

  The link setup and activation is performed asynchronously. If the
  link already exists, or if the caller attempts to create a link to
  itself, nothing is done. A detailed description of the link
  protocol can be found in the Distribution Protocol chapter of
  the ERTS User's Guide.

  [;;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.

  Failure:

   • [;;4mbadarg[0m if [;;4mPidOrPort[0m does not identify a process or a node
     local port.

   • [;;4mnoproc[0m linkee does not exist and it is "cheap" to check if
     it exists as described above.

[;1m  link(PidOrPort, OptList)[0m

[;;4mSince[0m:
  OTP @OTP-19198@

  Provides an option list for modification of the link functionality
  provided by [;;4mlink/1[0m. The [;;4mPidOrPort[0m argument has the same
  meaning as when passed to [;;4mlink/1[0m.

  Currently available options:

   • [;;4mpriority[0m - Since OTP @OTP-19198@

     Enables priority message reception of [;;4mEXIT[0m messages due to
     the link for the calling process. If the link already exists
     without priority message reception enabled for the link,
     priority message reception will be enabled on the existing
     link. If the link already exists with priority message
     reception enabled and this option is not passed or [;;4mlink/1[0m
     is called, priority message reception for this link will be
     disabled.

     Note that priority message reception due to the link is 
     only enabled for the process that passed this option. If
     the linked process also wants to enable priority message
     reception, it needs to call [;;4mlink/2[0m passing the [;;4mpriority[0m
     option itself.

  [;;4mWarning[0m

       You very seldom need to resort to using priority
       messages and you may cause issues instead of solving
       issues if not used with care.

     For more information see the Adding Messages to the Message
     Queue section of the Erlang Reference Manual.
