1mmap_shared(3) Library Functions Manual mmap_shared(3)
2
3
4
6 mmap_shared - memory map a file for reading and writing
7
9 #include <mmap.h>
10
11 char* mmap_shared(const char* filename,size_t* filesize);
12
14 mmap_shared opens filename for reading and writing, maps the whole file
15 into memory, closes the file, writes the length of the file to filesize
16 and returns a pointer to the mapped file.
17
18 The file is mapped shared. Changes done to the mapped region are writ‐
19 ten to disk and are visible to other processes reading from the file or
20 mapping the same file into memory.
21
22 The file is unmapped by the operating system if the process terminates.
23 It can also be manually unmapped by calling munmap from <sys/mman.h>.
24
25 To write changes to disk immediately, you can use msync from
26 <sys/mman.h>.
27
28 If the file could not be opened or mapped, (void*)0 is returned.
29
31 munmap(2), msync(2)
32
33
34
35 mmap_shared(3)