60d152d5ee
In the face of MX_POL_BAD_HANDLE, a bad handle error is fatal, but closing the "known never a handle" handle is similar to free(NULL) and is a reasonable strategy for cleanup. It's a different situation than "program double-closed a handle" or "program closed some random not a handle thing". Change-Id: I25410ee3040ec062700a4ca4d363841ca2b623c0
974 B
974 B
mx_handle_close
NAME
handle_close - close a handle
SYNOPSIS
#include <magenta/syscalls.h>
mx_status_t mx_handle_close(mx_handle_t handle);
DESCRIPTION
handle_close() closes a handle, causing the underlying object to be reclaimed by the kernel if no other handles to it exist.
If the handle was used in a pending object_wait_one or a object_wait_many call, the wait will be aborted.
If the handle was the next to last handle to the object. The last handle to the object will assert the MX_SIGNAL_LAST_HANDLE signal.
It is not an error to close the special "never a valid handle" MX_HANDLE_INVALID, similar to free(NULL) being a valid call.
RETURN VALUE
handle_close() returns MX_OK on success.
ERRORS
MX_ERR_BAD_HANDLE handle isn't a valid handle.