1.\" $NetBSD: minherit.2,v 1.20 2014/08/05 15:01:03 riastradh Exp $ 2.\" 3.\" Copyright (c) 1991, 1993 4.\" The Regents of the University of California. All rights reserved. 5.\" 6.\" Redistribution and use in source and binary forms, with or without 7.\" modification, are permitted provided that the following conditions 8.\" are met: 9.\" 1. Redistributions of source code must retain the above copyright 10.\" notice, this list of conditions and the following disclaimer. 11.\" 2. Redistributions in binary form must reproduce the above copyright 12.\" notice, this list of conditions and the following disclaimer in the 13.\" documentation and/or other materials provided with the distribution. 14.\" 3. Neither the name of the University nor the names of its contributors 15.\" may be used to endorse or promote products derived from this software 16.\" without specific prior written permission. 17.\" 18.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 19.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 22.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28.\" SUCH DAMAGE. 29.\" 30.\" @(#)minherit.2 8.1 (Berkeley) 6/9/93 31.\" 32.Dd August 5, 2014 33.Dt MINHERIT 2 34.Os 35.Sh NAME 36.Nm minherit 37.Nd control the inheritance of pages 38.Sh LIBRARY 39.Lb libc 40.Sh SYNOPSIS 41.In sys/mman.h 42.Ft int 43.Fn minherit "void *addr" "size_t len" "int inherit" 44.Sh DESCRIPTION 45The 46.Fn minherit 47system call changes the specified range of virtual addresses to have 48the inheritance characteristic 49.Fa inherit , 50which determines how 51.Xr fork 2 52will map the region in the child process. 53The supported inheritance characteristics are: 54.Bl -tag -offset abcd -width MAP_INHERIT_DEFAULT 55.It MAP_INHERIT_COPY 56The child is given a private copy of the region: writes from parent or 57child are not seen by the other. 58.It MAP_INHERIT_NONE 59The region is unmapped in the child. 60.It MAP_INHERIT_SHARE 61The child is shares the region with the parent: writes from parent and 62child are seen by both. 63.It MAP_INHERIT_ZERO 64The region is mapped in the child to anonymous pages filled with 65zeros. 66.El 67.Pp 68Normally, the parent's virtual address space is copied for the child 69as if with 70.Dv MAP_INHERIT_COPY , 71for which the alias 72.Dv MAP_INHERIT_DEFAULT 73is provided. 74Regions in the parent mapped using 75.Xr mmap 2 76with the 77.Dv MAP_SHARED 78flag are by default shared with the child as if with 79.Dv MAP_INHERIT_SHARED . 80.Pp 81Not all implementations will guarantee that the inheritance characteristic 82can be set on a page basis; 83the granularity of changes may be as large as an entire region. 84.Sh RETURN VALUES 85.Rv -std minherit 86.Sh ERRORS 87.Fn minherit 88will fail if: 89.Bl -tag -width Er 90.It Bq Er EINVAL 91An invalid region or invalid parameters were specified. 92.El 93.Sh SEE ALSO 94.Xr fork 2 , 95.Xr madvise 2 , 96.Xr mincore 2 , 97.Xr mmap 2 , 98.Xr mprotect 2 , 99.Xr msync 2 , 100.Xr munmap 2 101.Sh HISTORY 102The 103.Fn minherit 104function first appeared in 105.Ox . 106.Sh BUGS 107If a particular port does not support page-granularity 108inheritance, there's no way to figure out how large a region is 109actually affected by 110.Fn minherit . 111