Close an open file descriptor.
fd_close() function is used to close an open file descriptor. For sockets, this function will flush the data before closing the socket.
;;; Note: This is similar to `close` in POSIX. ;;; Close a file descriptor. (@interface func (export "fd_close") (param $fd $fd) (result $error (expected (error $errno))) )
ctx: A mutable reference to the function environment.
fd: The file descriptor mapping to an open file to close.
The function returns a
Result containing an
Errno value indicating the success or failure of the operation. An
Errno::Success value indicates a successful closure.
The function can return the following errors:
Errno::Isdir: If the provided
fdcorresponds to a directory.
Errno::Badf: If the provided
fdis invalid or not open.
This function has been instrumented with debug-level logging. It will log the following information:
pid: The process ID of the current execution context.
%fd: The file descriptor being closed.
err: Any encountered error during the closing process.
fd_close() function is used to close an open file descriptor. It releases any resources associated with the file descriptor. For sockets, it ensures that any pending data is flushed before closing the socket.