blob: d8d07faa308de72ed74b940d85f683c039d27210 (
plain)
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
|
'\" t
.\" Copyright (c) 2025 Bruce Hill
.\" All rights reserved.
.\"
.TH at_cleanup 3 2025-11-29 "Tomo man-pages"
.SH NAME
at_cleanup \- register a cleanup function
.SH LIBRARY
Tomo Standard Library
.SH SYNOPSIS
.nf
.BI at_cleanup\ :\ func(fn:\ func()\ ->\ Void)
.fi
.SH DESCRIPTION
Register a function that runs at cleanup time for Tomo programs. Cleanup time happens when a program exits (see `atexit()` in C), or immediately before printing error messages in a call to `fail()`. This allows for terminal cleanup so error messages can be visible as the program shuts down.
.SH ARGUMENTS
.TS
allbox;
lb lb lbx lb
l l l l.
Name Type Description Default
fn func() A function to run at cleanup time. -
.TE
.SH RETURN
Nothing.
.SH NOTES
Use this API very carefully, because errors that occur during cleanup functions may make it extremely hard to figure out what's going on. Cleanup functions should be designed to not error under any circumstances.
.SH EXAMPLES
.EX
at_cleanup(func()
(/tmp/file.txt).remove(ignore_missing=yes)
)
.EE
|