mmap.2: Minor fixes to Cyril Hrubis's patch

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
This commit is contained in:
Michael Kerrisk 2013-02-25 09:06:12 +01:00
parent 2e43522f07
commit a780f17be1
1 changed files with 15 additions and 8 deletions

View File

@ -612,14 +612,21 @@ fails with the error
.B EINVAL
for this case.
POSIX specifies that system shall always zero fill any partial page at the end
of the object and that system will newer write any modification of object
beyond its end. On Linux when you write data to such partial page after the end
of the object the data stays in page cache even after you closed and unmaped
the file and although the data are newer written to the file itself subsequent
mappings may see the modified content. In some cases this could be fixed by
calling msync before the unmap takes place, this however doesn't work on tmpfs
(for example when using shm ipc interface).
POSIX specifies that the system shall always
zero fill any partial page at the end
of the object and that system will never write any modification of the
object beyond its end.
On Linux, when you write data to such partial page after the end
of the object, the data stays in the page cache even after the file
is closed and unmapped
and even though the data is never written to the file itself,
subsequent mappings may see the modified content.
In some cases, this could be fixed by calling
.BR msync (2)
before the unmap takes place;
however, this doesn't work on tmpfs
(for example, when using POSIX shared memory interface documented in
.BR shm_overview (7)).
.SH EXAMPLE
.\" FIXME . Add an example here that uses an anonymous shared region for
.\" IPC between parent and child.