Skip to content

Commit 120467f

Browse files
fcevadojosevalim
authored andcommitted
Add section to Process.exit/2 with differences to Kernel.exit/1 (#14238)
1 parent 4b09a83 commit 120467f

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

lib/elixir/lib/process.ex

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,16 @@ defmodule Process do
219219
220220
Inlined by the compiler.
221221
222+
> #### Differences to `Kernel.exit/1` {: .info }
223+
>
224+
> The functions `Kernel.exit/1` and `Process.exit/2` are
225+
> named similarly but provide very different functionalities. The
226+
> `Kernel:exit/1` function should be used when the intent is to stop the current
227+
> process while `Process.exit/2` should be used when the intent is to send an
228+
> exit signal to another process. Note also that `Kernel.exit/1` can be caught
229+
> with `try/1` while `Process.exit/2` can only be handled by trapping exits and
230+
> when the signal is different than `:kill`.
231+
222232
## Examples
223233
224234
Process.exit(pid, :kill)

0 commit comments

Comments
 (0)