25 lines
859 B
Raw Normal View History

2001-11-25 23:50:09 +00:00
.TH mmap_shared 3
mmap_shared \- memory map a file for reading and writing
.B #include <mmap.h>
extern char* \fBmmap_shared\fP(const char* \fIfilename\fR,unsigned long* \fIfilesize\fR);
mmap_shared opens \fIfilename\fR for reading and writing, maps the
whole file into memory, closes the file, writes the length of the file
to \fIfilesize\fR and returns a pointer to the mapped file.
The file is mapped shared. Changes done to the mapped region are
written to disk and are visible to other processes reading from the file
or mapping the same file into memory.
The file is unmapped by the operating system if the process terminates.
It can also be manually unmapped by calling \fBmunmap\fR from
To write changes to disk immediately, you can use msync from
munmap(2), msync(2)