(38 lines)
1 '\" t2 .\" Copyright (c) 2026 Bruce Hill3 .\" All rights reserved.4 .\"5 .TH at_cleanup 3 2026-03-08 "Tomo man-pages"6 .SH NAME7 at_cleanup \- register a cleanup function8 .SH LIBRARY9 Tomo Standard Library10 .SH SYNOPSIS11 .nf12 .BI at_cleanup\ :\ func(fn:\ func()\ ->\ Void)13 .fi14 .SH DESCRIPTION15 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.18 .SH ARGUMENTS20 .TS21 allbox;22 lb lb lbx23 l l l.24 Name Type Description25 fn func() A function to run at cleanup time.26 .TE27 .SH RETURN28 Nothing.30 .SH NOTES31 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.33 .SH EXAMPLES34 .EX35 at_cleanup(func()36 _ := (/tmp/file.txt).remove(ignore_missing=yes)37 )38 .EE