summaryrefslogtreecommitdiff
path: root/lib/stdlib/test/shell_docs_SUITE_data/unknown_erlang_unlink_1_func.txt
blob: 23fecba59cbbd220131a90bd223d85a73e66b7f4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39

  -spec unlink(Id) -> true when Id :: pid() | port().

  Removes the link, if there is one, between the calling process and
  the process or port referred to by Id.

  Returns true and does not fail, even if there is no link to Id,
  or if Id does not exist.

  Once unlink(Id) has returned, it is guaranteed that the link
  between the caller and the entity referred to by Id has no
  effect on the caller in the future (unless the link is setup
  again). If the caller is trapping exits, an {'EXIT', Id, _}
  message from the link can have been placed in the caller's message
  queue before the call.

  Notice that the {'EXIT', Id, _} message can be the result of the
  link, but can also be the result of Id calling exit/2.
  Therefore, it can be appropriate to clean up the message queue
  when trapping exits after the call to unlink(Id), as follows:

    unlink(Id),
    receive
        {'EXIT', Id, _} ->
            true
    after 0 ->
            true
    end

  Note:
    Before Erlang/OTP R11B (ERTS 5.5) unlink/1 behaved
    completely asynchronously, that is, the link was active until
    the "unlink signal" reached the linked entity. This had an
    undesirable effect, as you could never know when you were
    guaranteed not to be effected by the link.

    The current behavior can be viewed as two combined operations:
    asynchronously send an "unlink signal" to the linked entity
    and ignore any future results of the link.