1.\" $OpenBSD: minherit.2,v 1.17 2024/01/21 17:46:03 deraadt 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 $Mdocdate: January 21 2024 $ 33.Dt MINHERIT 2 34.Os 35.Sh NAME 36.Nm minherit 37.Nd control the inheritance of pages 38.Sh SYNOPSIS 39.In sys/mman.h 40.Ft int 41.Fn minherit "void *addr" "size_t len" "int inherit" 42.Sh DESCRIPTION 43The 44.Fn minherit 45system call 46changes the specified pages to have the inheritance characteristic 47.Fa inherit . 48A page's inheritance characteristic controls how it will be mapped 49in child processes as created by 50.Xr fork 2 . 51.Pp 52The possible inheritance characteristics are: 53.Pp 54.Bl -tag -width MAP_INHERIT_SHARE -offset indent -compact 55.It Dv MAP_INHERIT_NONE 56Pages are not mapped in the child process. 57.It Dv MAP_INHERIT_COPY 58Private copy of pages are mapped in the child process. 59.It Dv MAP_INHERIT_SHARE 60Mapped pages are shared between the parent and child processes. 61.It Dv MAP_INHERIT_ZERO 62New anonymous pages (initialized to all zero bytes) 63are mapped in the child process. 64.El 65.Pp 66Not all implementations will guarantee that the inheritance characteristic 67can be set on a page basis; 68the granularity of changes may be as large as an entire region. 69.Sh RETURN VALUES 70.Rv -std 71.Sh ERRORS 72The 73.Fn minherit 74system call will fail if: 75.Bl -tag -width Er 76.It Bq Er EPERM 77The 78.Fa addr 79and 80.Fa len 81parameters specify a region that contains 82at least one page which is immutable, or 83.Dv MAP_INHERIT_ZERO 84is being requested on a page without 85.Dv PROT_WRITE 86permission. 87.It Bq Er EINVAL 88The virtual address range specified by the 89.Fa addr 90and 91.Fa len 92arguments is not valid. 93.It Bq Er EINVAL 94The 95.Fa inherit 96argument is invalid. 97.El 98.Sh SEE ALSO 99.Xr madvise 2 , 100.Xr mimmutable 2 , 101.Xr mprotect 2 , 102.Xr msync 2 , 103.Xr munmap 2 104.Sh HISTORY 105The 106.Fn minherit 107function first appeared in 108.Ox 2.0 . 109