<lib/fdio/unsafe.h> in fdio

Header source code

fdio_unsafe_borrow_channel(…) {:#fdio_unsafe_borrow_channel}

Declaration source code

Returns the handle corresponding to the underlying fdio, if there is one. Returns ZX_HANDLE_INVALID otherwise.

Since this handle is borrowed from the underlying fdio_t, it is unsafe to close it or use it after fdio_unsafe_release is called.

fdio_unsafe_fd_to_io(…) {:#fdio_unsafe_fd_to_io}

Declaration source code

This looks up a file descriptor, and if it exists, upreferences the fdio_t under it and returns that. fdio_unsafe_release() must be called later to release the reference.

If the fd does not exist, it returns NULL

fdio_unsafe_release(…) {:#fdio_unsafe_release}

Declaration source code

Releases a reference on a fdio_t. Used to “return” a fdio_t obtained from fdio_unsafe_fd_to_io() when you're done with it.

fdio_unsafe_wait_begin(…) {:#fdio_unsafe_wait_begin}

Declaration source code

This given a fdio_t, and a bitmask of posix-style events (EPOLLIN, EPOLLOUT, EPOLLERR), this returns a handle that may be waited upon and a bitmask of which signals to wait on for the desired events.

The handle belongs to the fdio_t, is not duplicated, and may be closed() by the fdio library but MUST NOT be closed by the caller.

If waiting is not supported by this fdio_t, the returned handle is ZX_HANDLE_INVALID.

This function is only safe to call on a fdio_t you hold a reference to. It is not required that fdio_unsafe_wait_end() be called after this.

fdio_unsafe_wait_end(…) {:#fdio_unsafe_wait_end}

Declaration source code

This given a set of signals observed on a handle obtained from fdio_unsafe_wait_begin() returns a set of posix-style events that are indicated.

This function is only safe to call on a fdio_t you hold a reference to.