From e263bda8249ece2cc2b2134cd2c28bcc5fa8be35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20M=C3=BCller?= Date: Wed, 3 Apr 2024 13:56:55 +0200 Subject: [PATCH 1/2] Improve documentation for `at_exit` handlers Explain conditions when `at_exit` handlers execute. --- src/kernel.cr | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/kernel.cr b/src/kernel.cr index 78f84d292bfa..af514f8999ca 100644 --- a/src/kernel.cr +++ b/src/kernel.cr @@ -491,7 +491,16 @@ def pp(**objects) pp(objects) unless objects.empty? end -# Registers the given `Proc` for execution when the program exits. +# Registers the given `Proc` for execution when the program exits regularly. +# +# A regular exit happens when either +# * the main fiber reaches the end of the program, +# * the main fiber rescues an unhandled exception, or +# * `::exit` is called. +# +# `Process.exit` does *not* trigger `at_exit` handlers, nor does external process +# termination (see `Process.on_terminate` for handling that). +# # If multiple handlers are registered, they are executed in reverse order of registration. # # ``` From e7d83f465dbb47e1581cb4a933c06f06c7c6e82b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20M=C3=BCller?= Date: Wed, 3 Apr 2024 14:24:41 +0200 Subject: [PATCH 2/2] Fix format --- src/kernel.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/kernel.cr b/src/kernel.cr index af514f8999ca..1ca8d4073243 100644 --- a/src/kernel.cr +++ b/src/kernel.cr @@ -498,7 +498,7 @@ end # * the main fiber rescues an unhandled exception, or # * `::exit` is called. # -# `Process.exit` does *not* trigger `at_exit` handlers, nor does external process +# `Process.exit` does *not* trigger `at_exit` handlers, nor does external process # termination (see `Process.on_terminate` for handling that). # # If multiple handlers are registered, they are executed in reverse order of registration.