git.samba.org
/
tridge
/
junkcode.git
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
history
|
raw
|
HEAD
tweaks
[tridge/junkcode.git]
/
mmap2.c
1
#include <stdio.h>
2
#include <unistd.h>
3
#include <sys/mman.h>
4
#include <fcntl.h>
5
#include <sys/file.h>
6
7
int main(void)
8
{
9
int fd;
10
int i;
11
char *p;
12
13
fd = open("mmap.tst", O_RDWR|O_CREAT|O_TRUNC, 0600);
14
15
ftruncate(fd, 8192);
16
17
p = mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
18
19
while (1) {
20
sleep(4);
21
p[1024]++;
22
pwrite(fd, p, 1, 0);
23
}
24
25
return 0;
26
}