The following http://siber.cankaya.edu.tr/SystemsProgramming/cfiles/mmap-read.ccode (see Fig. 6.3.1) reads the number, prints it, and replaces it in the memory-mapped file with double the value.
Figure 6.5:
Write a Random Number to a Memory-Mapped File
|
Figure 6.6:
Read an Integer from a Memory-Mapped File, and Double It
|
$ ./mmap-write /tmp/integer-file
$ cat /tmp/integer-file
42
$ ./mmap-read /tmp/integer-file
value: 42
$ cat /tmp/integer-file
84