1999-08-28 00:22:10 +00:00
|
|
|
.\" $FreeBSD$
|
1996-02-23 19:56:55 +00:00
|
|
|
.\"
|
|
|
|
.\" Copyright (c) 1991, 1993
|
|
|
|
.\" The Regents of the University of California. All rights reserved.
|
|
|
|
.\"
|
|
|
|
.\" Redistribution and use in source and binary forms, with or without
|
|
|
|
.\" modification, are permitted provided that the following conditions
|
|
|
|
.\" are met:
|
|
|
|
.\" 1. Redistributions of source code must retain the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer.
|
|
|
|
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer in the
|
|
|
|
.\" documentation and/or other materials provided with the distribution.
|
|
|
|
.\" 4. Neither the name of the University nor the names of its contributors
|
|
|
|
.\" may be used to endorse or promote products derived from this software
|
|
|
|
.\" without specific prior written permission.
|
|
|
|
.\"
|
|
|
|
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
.\" SUCH DAMAGE.
|
|
|
|
.\"
|
|
|
|
.\" @(#)minherit.2 8.1 (Berkeley) 6/9/93
|
|
|
|
.\"
|
2000-12-11 15:15:20 +00:00
|
|
|
.Dd February 17, 1996
|
1996-02-23 19:56:55 +00:00
|
|
|
.Dt MINHERIT 2
|
|
|
|
.Os
|
|
|
|
.Sh NAME
|
|
|
|
.Nm minherit
|
|
|
|
.Nd control the inheritance of pages
|
2000-04-21 09:42:15 +00:00
|
|
|
.Sh LIBRARY
|
|
|
|
.Lb libc
|
1996-02-23 19:56:55 +00:00
|
|
|
.Sh SYNOPSIS
|
2001-10-01 16:09:29 +00:00
|
|
|
.In sys/mman.h
|
1996-02-23 19:56:55 +00:00
|
|
|
.Ft int
|
1997-12-31 01:22:01 +00:00
|
|
|
.Fn minherit "void *addr" "size_t len" "int inherit"
|
1996-02-23 19:56:55 +00:00
|
|
|
.Sh DESCRIPTION
|
|
|
|
The
|
|
|
|
.Fn minherit
|
|
|
|
system call
|
|
|
|
changes the specified pages to have the inheritance characteristic
|
|
|
|
.Fa inherit .
|
|
|
|
Not all implementations will guarantee that the inheritance characteristic
|
|
|
|
can be set on a page basis;
|
|
|
|
the granularity of changes may be as large as an entire region.
|
2001-08-24 19:28:00 +00:00
|
|
|
.Fx
|
|
|
|
is capable of adjusting inheritance characteristics on a page basis.
|
|
|
|
Inheritance only effects children created by
|
|
|
|
.Fn fork .
|
|
|
|
It has no effect on
|
|
|
|
.Fn exec .
|
2001-08-27 08:26:57 +00:00
|
|
|
exec'd processes replace their address space entirely.
|
2002-12-18 09:22:32 +00:00
|
|
|
This system call also
|
2001-08-27 08:26:57 +00:00
|
|
|
has no effect on the parent's address space (other than to potentially
|
2001-08-24 19:28:00 +00:00
|
|
|
share the address space with its children).
|
|
|
|
.Pp
|
2001-08-27 08:26:57 +00:00
|
|
|
Inheritance is a rather esoteric feature largely superseded by the
|
|
|
|
.Dv MAP_SHARED
|
|
|
|
feature of
|
2001-08-24 19:28:00 +00:00
|
|
|
.Fn mmap .
|
|
|
|
However, it is possible to use
|
|
|
|
.Fn minherit
|
|
|
|
to share a block of memory between parent and child that has been mapped
|
2001-08-27 08:26:57 +00:00
|
|
|
.Dv MAP_PRIVATE .
|
|
|
|
That is, modifications made by parent or child are shared but
|
2001-08-24 19:28:00 +00:00
|
|
|
the original underlying file is left untouched.
|
2001-08-27 08:26:57 +00:00
|
|
|
.Bl -tag -width ".Dv INHERIT_SHARE"
|
2001-08-24 19:45:59 +00:00
|
|
|
.It Dv INHERIT_SHARE
|
2001-08-24 19:28:00 +00:00
|
|
|
This option causes the address space in question to be shared between
|
2001-08-27 08:26:57 +00:00
|
|
|
parent and child.
|
|
|
|
It has no effect on how the original underlying backing
|
2001-08-24 19:28:00 +00:00
|
|
|
store was mapped.
|
2001-08-24 19:45:59 +00:00
|
|
|
.It Dv INHERIT_NONE
|
2001-08-27 08:26:57 +00:00
|
|
|
This option prevents the address space in question from being inherited
|
|
|
|
at all.
|
|
|
|
The address space will be unmapped in the child.
|
2001-08-24 19:45:59 +00:00
|
|
|
.It Dv INHERIT_COPY
|
2001-08-24 19:43:45 +00:00
|
|
|
This option causes the child to inherit the address space as copy-on-write.
|
|
|
|
This option also has an unfortunate side effect of causing the parent
|
2001-08-27 08:26:57 +00:00
|
|
|
address space to become copy-on-write when the parent forks.
|
|
|
|
If the original mapping was
|
|
|
|
.Dv MAP_SHARED ,
|
|
|
|
it will no longer be shared in the parent
|
|
|
|
after the parent forks and there is no way to get the previous
|
2001-08-24 19:43:45 +00:00
|
|
|
shared-backing-store mapping without unmapping and remapping the address
|
|
|
|
space in the parent.
|
2001-08-24 19:28:00 +00:00
|
|
|
.El
|
1997-01-12 00:38:36 +00:00
|
|
|
.Sh RETURN VALUES
|
2001-08-09 13:32:13 +00:00
|
|
|
.Rv -std minherit
|
1997-01-12 00:38:36 +00:00
|
|
|
.Sh ERRORS
|
|
|
|
The
|
|
|
|
.Fn minherit
|
2002-12-18 09:22:32 +00:00
|
|
|
system call will fail if:
|
1997-01-12 00:38:36 +00:00
|
|
|
.Bl -tag -width Er
|
|
|
|
.It Bq Er EINVAL
|
|
|
|
The virtual address range specified by the
|
|
|
|
.Fa addr
|
|
|
|
and
|
|
|
|
.Fa len
|
|
|
|
arguments is not valid.
|
1999-03-15 00:14:57 +00:00
|
|
|
.It Bq Er EACCES
|
1997-01-12 00:38:36 +00:00
|
|
|
The flags specified by the
|
|
|
|
.Fa inherit
|
|
|
|
argument were not valid for the pages specified
|
|
|
|
by the
|
|
|
|
.Fa addr
|
|
|
|
and
|
|
|
|
.Fa len
|
|
|
|
arguments.
|
|
|
|
.El
|
1996-02-23 19:56:55 +00:00
|
|
|
.Sh SEE ALSO
|
|
|
|
.Xr fork 2 ,
|
2001-07-15 07:53:42 +00:00
|
|
|
.Xr madvise 2 ,
|
|
|
|
.Xr mincore 2 ,
|
|
|
|
.Xr mprotect 2 ,
|
1996-02-23 19:56:55 +00:00
|
|
|
.Xr msync 2 ,
|
|
|
|
.Xr munmap 2 ,
|
|
|
|
.Xr rfork 2
|
|
|
|
.Sh HISTORY
|
|
|
|
The
|
|
|
|
.Fn minherit
|
2002-12-18 09:22:32 +00:00
|
|
|
system call first appeared in
|
2007-09-21 14:05:26 +00:00
|
|
|
.Ox
|
|
|
|
and then in
|
|
|
|
.Fx 2.2.0 .
|
2005-01-20 09:17:07 +00:00
|
|
|
.Sh BUGS
|
|
|
|
Once you set inheritance to
|
|
|
|
.Dv MAP_PRIVATE
|
|
|
|
or
|
|
|
|
.Dv MAP_SHARED ,
|
|
|
|
there is no way to recover the original copy-on-write semantics
|
|
|
|
short of unmapping and remapping the area.
|