OSDN Git Service

LDP: Update original to LDP v3.79
[linuxjm/LDP_man-pages.git] / original / man2 / mlock.2
index 45f5f1d..ef73458 100644 (file)
@@ -1,9 +1,8 @@
-.\" Hey Emacs! This file is -*- nroff -*- source.
-.\"
 .\" Copyright (C) Michael Kerrisk, 2004
 .\"    using some material drawn from earlier man pages
 .\"    written by Thomas Kuhn, Copyright 1996
 .\"
+.\" %%%LICENSE_START(GPLv2+_DOC_FULL)
 .\" This is free documentation; you can redistribute it and/or
 .\" modify it under the terms of the GNU General Public License as
 .\" published by the Free Software Foundation; either version 2 of
 .\" GNU General Public License for more details.
 .\"
 .\" You should have received a copy of the GNU General Public
-.\" License along with this manual; if not, write to the Free
-.\" Software Foundation, Inc., 59 Temple Place, Suite 330,
-.\" Boston, MA 02111, USA.
+.\" License along with this manual; if not, see
+.\" <http://www.gnu.org/licenses/>.
+.\" %%%LICENSE_END
 .\"
-.TH MLOCK 2 2010-10-30 "Linux" "Linux Programmer's Manual"
+.TH MLOCK 2 2014-04-14 "Linux" "Linux Programmer's Manual"
 .SH NAME
 mlock, munlock, mlockall, munlockall \- lock and unlock memory
 .SH SYNOPSIS
@@ -52,7 +51,7 @@ respectively unlocking part or all of the calling process's virtual
 address space, so that pages in the specified virtual address range may
 once more to be swapped out if required by the kernel memory manager.
 Memory locking and unlocking are performed in units of whole pages.
-.SS "mlock() and munlock()"
+.SS mlock() and munlock()
 .BR mlock ()
 locks pages in the address range starting at
 .I addr
@@ -71,7 +70,7 @@ and continuing for
 bytes.
 After this call, all pages that contain a part of the specified
 memory range can be moved to external swap space again by the kernel.
-.SS "mlockall() and munlockall()"
+.SS mlockall() and munlockall()
 .BR mlockall ()
 locks all pages mapped into the address space of the
 calling process.
@@ -95,7 +94,7 @@ the process.
 Lock all pages which will become mapped into the address space of the
 process in the future.
 These could be for instance new pages required
-by a growing heap and stack as well as new memory mapped files or
+by a growing heap and stack as well as new memory-mapped files or
 shared memory regions.
 .PP
 If
@@ -114,7 +113,7 @@ signal to the process.
 .BR munlockall ()
 unlocks all pages mapped into the address space of the
 calling process.
-.SH "RETURN VALUE"
+.SH RETURN VALUE
 On success these system calls return 0.
 On error, \-1 is returned,
 .I errno
@@ -143,19 +142,9 @@ half of RAM.
 .\" pages, which of course is not true.  (MTK, Nov 04, kernel 2.4.28)
 .TP
 .B EPERM
-(Linux 2.6.9 and later) the caller was not privileged
+The caller is not privileged, but needs privilege
 .RB ( CAP_IPC_LOCK )
-and its
-.B RLIMIT_MEMLOCK
-soft resource limit was 0.
-.TP
-.B EPERM
-(Linux 2.6.8 and earlier)
-The calling process has insufficient privilege to call
-.BR munlockall ().
-Under Linux the
-.B CAP_IPC_LOCK
-capability is required.
+to perform the requested operation.
 .\"SVr4 documents an additional EAGAIN error code.
 .LP
 For
@@ -167,8 +156,11 @@ and
 Some or all of the specified address range could not be locked.
 .TP
 .B EINVAL
-.I len
-was negative.
+The result of the addition
+.IR start + len
+was less than
+.IR start
+(e.g., the addition may have resulted in an overflow).
 .TP
 .B EINVAL
 (Not on Linux)
@@ -191,7 +183,7 @@ For
 .B EPERM
 (Linux 2.6.8 and earlier) The caller was not privileged
 .RB ( CAP_IPC_LOCK ).
-.SH "CONFORMING TO"
+.SH CONFORMING TO
 POSIX.1-2001, SVr4.
 .SH AVAILABILITY
 On POSIX systems on which
@@ -218,7 +210,7 @@ is defined in \fI<unistd.h>\fP to a value greater than 0.
 .\" POSIX.1-2001: It shall be defined to -1 or 0 or 200112L.
 .\" -1: unavailable, 0: ask using sysconf().
 .\" glibc defines it to 1.
-.SH "NOTES"
+.SH NOTES
 Memory locking has two main applications: real-time algorithms and
 high-security data processing.
 Real-time applications require
@@ -255,6 +247,13 @@ Memory locks are not inherited by a child created via
 and are automatically removed (unlocked) during an
 .BR execve (2)
 or when the process terminates.
+The
+.BR mlockall ()
+.B MCL_FUTURE
+setting is not inherited by a child created via
+.BR fork (2)
+and is cleared during an
+.BR execve (2).
 
 The memory lock on an address range is automatically removed
 if the address range is unmapped via
@@ -272,7 +271,7 @@ for the corresponding range or by
 Pages which are mapped to several locations or by several processes stay
 locked into RAM as long as they are locked at least at one location or by
 at least one process.
-.SS "Linux Notes"
+.SS Linux notes
 Under Linux,
 .BR mlock ()
 and
@@ -296,7 +295,7 @@ has locked using
 and
 .BR mmap (2)
 .BR MAP_LOCKED .
-.SS "Limits and permissions"
+.SS Limits and permissions
 In Linux 2.6.8 and earlier,
 a process must be privileged
 .RB ( CAP_IPC_LOCK )
@@ -309,7 +308,7 @@ that a privileged process can lock and the
 .B RLIMIT_MEMLOCK
 soft resource limit instead defines a limit on how much memory an
 unprivileged process may lock.
-.SH "BUGS"
+.SH BUGS
 In the 2.4 series Linux kernels up to and including 2.4.17,
 a bug caused the
 .BR mlockall ()
@@ -334,10 +333,19 @@ resource limit is encountered.
 .\" http://marc.theaimsgroup.com/?l=linux-kernel&m=113801392825023&w=2
 .\" "Rationale for RLIMIT_MEMLOCK"
 .\" 23 Jan 2006
-.SH "SEE ALSO"
+.SH SEE ALSO
 .BR mmap (2),
 .BR setrlimit (2),
 .BR shmctl (2),
 .BR sysconf (3),
 .BR proc (5),
 .BR capabilities (7)
+.SH COLOPHON
+This page is part of release 3.79 of the Linux
+.I man-pages
+project.
+A description of the project,
+information about reporting bugs,
+and the latest version of this page,
+can be found at
+\%http://www.kernel.org/doc/man\-pages/.