File: unknown_erlang_exit_func.txt

package info (click to toggle)
erlang 1%3A27.3.4.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 225,000 kB
  • sloc: erlang: 1,658,966; ansic: 405,769; cpp: 177,850; xml: 82,435; makefile: 15,031; sh: 14,401; lisp: 9,812; java: 8,603; asm: 6,541; perl: 5,836; python: 5,484; sed: 72
file content (110 lines) | stat: -rw-r--r-- 4,906 bytes parent folder | download | duplicates (2)
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110

  exit(Reason)

  Raises an exception of class exit with exit reason Reason.

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

  The intent of the exception class exit is that the current
  process should be stopped (for example when a message telling a
  process to stop is received).

  This function differ from error/1,2,3 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}

  Note

    If a process calls exit(kill) and does not catch the
    exception, it will terminate with exit reason kill and also
    emit exit signals with exit reason kill (not killed) to
    all linked processes. Such exit signals with exit reason kill
    can be trapped by the linked processes. Note that this means
    that signals with exit reason kill 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 erlang:exit/2.

  exit(Pid, Reason)

  Sends an exit signal with exit reason Reason to the process or
  port identified by Pid.

  The following behavior applies if Reason is any term, except 
  normal or kill, and P is the process or port identified by 
  Pid:

   • If P is not trapping exits, P exits with exit reason 
     Reason.

   • If P is trapping exits, the exit signal is transformed
     into a message {'EXIT', From, Reason}, where From is the
     process identifier of the process that sent the exit signal,
     and delivered to the message queue of P.

  The following behavior applies if Reason is the term normal
  and Pid is the identifier of a process P which is not the same
  as the process that invoked erlang:exit(Pid, normal) (the
  behavior when a process sends a signal with the normal reason to
  itself is described in the warning):

   • If P is trapping exits, the exit signal is transformed
     into a message {'EXIT', From, normal}, where From is the
     process identifier of the process that sent the exit signal,
     and delivered to P's message queue.

   • The signal has no effect if P is not trapping exits.

  If Reason is the atom kill, that is, if exit(Pid, kill) is
  called, an untrappable exit signal is sent to the process that is
  identified by Pid, which unconditionally exits with exit reason 
  killed. The exit reason is changed from kill to killed to
  hint to linked processes that the killed process got killed by a
  call to exit(Pid, kill).

  Note

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

  Warning

    The only scenario that has not been covered by the description
    above is when a process P sends an exit signal with reason 
    normal to itself, that is erlang:exit(self(), normal). The
    behavior in this scenario is as follows:

     • If P is trapping exits, the exit signal is transformed
       into a message {'EXIT', From, normal}, where From is 
       P's process identifier, and delivered to P's message
       queue.

     • P exits with reason normal if P is not trapping
       exits. Note that the behavior described above is
       different from when a process sends an exit signal with
       reason normal to another process. This is arguably
       strange but this behavior is kept for backward
       compatibility reasons.

  Note

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