osfmk/man/vm_inherit.html
Function - Set a VM region's inheritance attribute.
**kern\_return\_t vm\_inherit**** (vm\_task\_t **target\_task,** vm\_address\_t **address,** vm\_size\_t **size,** vm\_inherit\_t **new\_inheritance** );**
target_task[in task send right] The port for the task whose address space contains the region.
address[in scalar] The starting address for the region.
size[in scalar] The number of bytes in the region.
new_inheritance[in scalar] The new inheritance attribute for the region. Valid values are:
VM_INHERIT_SHARE Allows child tasks to share the region.
VM_INHERIT_COPY Gives child tasks a copy of the region.
VM_INHERIT_NONE Provides no access to the region for child tasks.
The vm_inherit function sets the inheritance attribute for a region within the specified task's address space. The inheritance attribute determines the type of access established for child tasks at task creation.
Because inheritance applies to virtual pages, the specified address and size are rounded to page boundaries, as follows: the region starts at the beginning of the virtual page containing address; it ends at the end of the virtual page containing address + size - 1. Because of this rounding to virtual page boundaries, the amount of memory affected may be greater than size. Use host_page_size to find the current virtual page size.
A parent and a child task can share the same physical memory only if the inheritance for the memory is set to VM_INHERIT_SHARE before the child task is created. Other than through the use of an external memory manager (see vm_map ), this is the only way that two tasks can share memory.
Note that all the threads within a task share the task's memory.
This interface is machine word length specific because of the virtual address parameter.
KERN_INVALID_ADDRESS The address is illegal or specifies a non-allocated region.
Functions: task_create, vm_map, vm_region,