Close v0.1.0

Source
Closes a file descriptor.

Package: Linux

Signature

func Close(fd: int32) -> int64;

Parameters

NameTypeDescription
fdint32File descriptor to close.

Returns

int640 on success, or a negative errno result on failure.

Description

After a successful close, fd no longer refers to the resource and may be reused by a later operation. Do not close a descriptor more than once.

Retrying Close after an error is unsafe on Linux because the descriptor may already have been released and reused. Handle the reported error without blindly repeating the call.

Example

import Linux::{ Close, IsError };

func Main() -> int {
    if IsError(Close(fd)) {
        return 1;
    }
    return 0;
}