From 120467f83c020af650f3648fc91689be649b3157 Mon Sep 17 00:00:00 2001 From: cevado Date: Wed, 29 Jan 2025 04:56:49 -0300 Subject: [PATCH] Add section to Process.exit/2 with differences to Kernel.exit/1 (#14238) --- lib/elixir/lib/process.ex | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/elixir/lib/process.ex b/lib/elixir/lib/process.ex index 43299a1b680..ef1c8c46a7f 100644 --- a/lib/elixir/lib/process.ex +++ b/lib/elixir/lib/process.ex @@ -219,6 +219,16 @@ defmodule Process do Inlined by the compiler. + > #### Differences to `Kernel.exit/1` {: .info } + > + > The functions `Kernel.exit/1` and `Process.exit/2` are + > named similarly but provide very different functionalities. The + > `Kernel:exit/1` function should be used when the intent is to stop the current + > process while `Process.exit/2` should be used when the intent is to send an + > exit signal to another process. Note also that `Kernel.exit/1` can be caught + > with `try/1` while `Process.exit/2` can only be handled by trapping exits and + > when the signal is different than `:kill`. + ## Examples Process.exit(pid, :kill)