## vm_inherit

Function - Set a VM region's inheritance attribute.

### SYNOPSIS

    kern_return_t   vm_inherit
                     (vm_task_t                   target_task,
                      vm_address_t                    address,
                      vm_size_t                          size,
                      vm_inherit_t            new_inheritance);

### PARAMETERS

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.

### DESCRIPTION

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.

### NOTES

This interface is machine word length specific because of the virtual address parameter.

### RETURN VALUES

KERN_INVALID_ADDRESS
  The address is illegal or specifies a non-allocated region.

### RELATED INFORMATION

Functions: task_create, vm_map, vm_region, norma_task_create.