GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
SHTK_CLEANUP_REGISTER(3) FreeBSD Library Functions Manual SHTK_CLEANUP_REGISTER(3)

shtk_cleanup_register
Installs cleanup handlers to be called on script termination

shtk_import cleanup

shtk_cleanup_register handler1 [.. handlerN]

The shtk_cleanup_register function installs one or more cleanup handlers, given in the handler1 to handlerN arguments as function names.

The registered handlers are executed in the order they are originally registered. Registration of handlers is idempotent.

The following example creates a temporary file and installs a cleanup handler to ensure that the file gets removed when the script terminates:
local pattern="${TMPDIR:-/tmp}/my_program.XXXXXX"

local temp_file="$(mktemp "${pattern}" 2>/dev/null)"
[ -f "${temp_file}" ] || shtk_cli_error "Failed to create temporary file"

eval "remove_temp_file() { rm -f '${temp_file}'; }"
shtk_cleanup_register remove_temp_file

shtk(3), shtk_cleanup(3)

shtk_cleanup_register first appeared in shtk 1.4.
November 5, 2014 FreeBSD 13.1-RELEASE

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.