1# zx_vmar_unmap_handle_close_thread_exit 2 3## NAME 4 5vmar_unmap_handle_close_thread_exit - unmap memory, close handle, exit 6 7## SYNOPSIS 8 9``` 10#include <zircon/syscalls.h> 11 12zx_status_t zx_vmar_unmap_handle_close_thread_exit(zx_handle_t vmar_handle, 13 zx_vaddr_t addr, size_t size, 14 zx_handle_t close_handle); 15``` 16 17## DESCRIPTION 18 19**vmar_unmap_handle_close_thread_exit**() does a sequence of three operations: 201. `zx_vmar_unmap(vmar_handle, addr, size);` 212. `zx_handle_close(close_handle);` 223. `zx_thread_exit();` 23 24The expectation is that the first operation unmaps a region including the 25calling thread's own stack. (It's not required, but it's permitted.) This 26is valid for this call, though it would be invalid for *zx_vmar_unmap*() or 27any other call. 28 29If the *vmar_unmap* operation is successful, then this call never returns. 30If `close_handle` is an invalid handle so that the *handle_close* operation 31fails, then the thread takes a trap (as if by `__builtin_trap();`). 32 33## RIGHTS 34 35TODO(ZX-2399) 36 37## RETURN VALUE 38 39**vmar_unmap_handle_close_thread_exit**() does not return on success. 40 41## ERRORS 42 43Same as [*zx_vmar_unmap*()](vmar_unmap.md). 44 45## NOTES 46 47The intended use for this is for a dying thread to unmap its own stack, 48close its own thread handle, and exit. The thread handle cannot be closed 49beforehand because closing the last handle to a thread kills that thread. 50The stack cannot be unmapped beforehand because the thread must have some 51stack space on which to make its final system calls. 52 53This call is used for detached threads, while 54[*futex_wake_handle_close_thread_exit*()](futex_wake_handle_close_thread_exit.md) 55is used for joinable threads. 56 57## SEE ALSO 58 59[vmar_unmap](vmar_unmap.md), 60[handle_close](handle_close.md), 61[thread_exit](thread_exit.md), 62[futex_wake_handle_close_thread_exit](futex_wake_handle_close_thread_exit.md). 63