xref: /netbsd/lib/libc/sys/minherit.2 (revision 6550d01e)
1.\"	$NetBSD: minherit.2,v 1.18 2006/10/13 20:52:57 wiz 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 October 7, 2006
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
48changes the specified range of virtual addresses to have the specified
49fork-time inheritance characteristic
50.Fa inherit ,
51which can be set to
52.Dv MAP_INHERIT_NONE ,
53.Dv MAP_INHERIT_COPY ,
54or
55.Dv MAP_INHERIT_SHARE .
56Also possible is
57.Dv MAP_INHERIT_DEFAULT ,
58which defaults to
59.Dv MAP_INHERIT_COPY .
60Not all implementations will guarantee that the inheritance characteristic
61can be set on a page basis;
62the granularity of changes may be as large as an entire region.
63.Pp
64Normally, the entire address space is marked
65.Dv MAP_INHERIT_COPY ;
66when the process calls
67.Fn fork ,
68the child receives a (virtual) copy of the entire address space.
69Pages or regions marked
70.Dv MAP_INHERIT_SHARE
71are shared between the address spaces, while pages or regions marked
72.Dv MAP_INHERIT_NONE
73will be unmapped in the child.
74.Sh RETURN VALUES
75.Rv -std minherit
76.Sh ERRORS
77.Fn minherit
78will fail if:
79.Bl -tag -width Er
80.It Bq Er EINVAL
81An invalid region or invalid parameters were specified.
82.El
83.Sh SEE ALSO
84.Xr fork 2 ,
85.Xr madvise 2 ,
86.Xr mincore 2 ,
87.Xr mprotect 2 ,
88.Xr msync 2 ,
89.Xr munmap 2
90.Sh HISTORY
91The
92.Fn minherit
93function first appeared in
94.Ox .
95.Sh BUGS
96If a particular port does not support page-granularity
97inheritance, there's no way to figure out how large a region is
98actually affected by
99.Fn minherit .
100