Skip to content

Commit 32a5c97

Browse files
authored
Docs: reorganize description of exit behavior in Process.exit/2 (#14728)
1 parent 86d5b3a commit 32a5c97

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

lib/elixir/lib/process.ex

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -202,24 +202,23 @@ defmodule Process do
202202
@doc """
203203
Sends an exit signal with the given `reason` to `pid`.
204204
205-
The following behavior applies if `reason` is any term except `:normal`
206-
or `:kill`:
205+
Exit behavior differs based on the value of `reason`:
207206
208-
1. If `pid` is not trapping exits, `pid` will exit with the given
209-
`reason`.
207+
- If `:normal`, `pid` will not exit unless it is the calling process, in
208+
which case it will exit with the reason `:normal`. If it is trapping exits,
209+
the exit signal is transformed into a message `{:EXIT, from, :normal}` and
210+
delivered to its message queue.
210211
211-
2. If `pid` is trapping exits, the exit signal is transformed into a
212-
message `{:EXIT, from, reason}` and delivered to the message queue
213-
of `pid`.
212+
- If `:kill`, which occurs when `Process.exit(pid, :kill)` is called, an
213+
untrappable exit signal is sent to `pid` which will unconditionally exit
214+
with reason `:killed`.
214215
215-
If `reason` is the atom `:normal`, `pid` will not exit (unless `pid` is
216-
the calling process, in which case it will exit with the reason `:normal`).
217-
If it is trapping exits, the exit signal is transformed into a message
218-
`{:EXIT, from, :normal}` and delivered to its message queue.
216+
- If any other term and `pid` is not trapping exits, `pid` will exit with
217+
the given `reason`.
219218
220-
If `reason` is the atom `:kill`, that is if `Process.exit(pid, :kill)` is called,
221-
an untrappable exit signal is sent to `pid` which will unconditionally exit
222-
with reason `:killed`.
219+
- If any other term and `pid` is trapping exits, the exit signal is
220+
transformed into a message `{:EXIT, from, reason}` and delivered to its
221+
message queue.
223222
224223
Inlined by the compiler.
225224

0 commit comments

Comments
 (0)