Handle2

handle2 is an ACOS technology used for automatic file handle closing.

Features
handle2 automagically closes file handles (objects used for file I/O) so that no handles can stay open when their reference is lost. ComputerCraft file handles are directly operating with the Java side. When a program that opened a file handle exits unexpectedly, the handle frequently stays open. This open handle cannot be closed any more because its reference is lost, however, Java prevents interacting with the target file because it has opened a handle on it. This situation requires a computer reboot to reset the filesystem, and until then can cause unexpected errors in other programs trying to interact with the targeted file.

ACOS solves this issue by keeping track of which handles are open and a complex structure of weak tables that tracks what function or program has a reference to the particular file handle. Once all references are gone and the handle was not closed yet, handle2automatically closes it and removes it from memory.