Home Contents | # Closing files | Rawio | Core4 Lua Event System

## SYNOPSIS

1. handle:close()
2. handle:detach()

## DESCRIPTION

rawio:close() closes an open file by calling the operating systems' close function and discards the file handle.

rawio:detach() just discards the Lua file handle, but keeps the file open in the operating system. The latter function is useful when working with the standard file descriptors 0, 1 and 2 which you usually don't want to close.

## NOTES

Handles are automatically closed when they are garbage collected, but that takes an unpredictable amount of time to happen.

## BUGS

The automatic close at garbage collection time will happily close standard file descriptors, too, possibly pulling the ground from under your feet.

## SEE ALSO

rawio.attach, rawio:blocking, rawio:canReadLine, rawio:clearError, rawio:connect, rawio:lastError, rawio:line, rawio:lines, rawio.access, rawio.open, rawio:read, rawio:copy, rawio.stat, rawio.statfs, rawio:writet, rawio:writes, rawio:write