mmap的问题,帮看看。。。
程序代码:#include <stdlib.h>
#include <sys/mman.h>
#include <fcntl.h>
int main(void)
{
int *p;
int fd = open("hello", O_RDWR);
if (fd < 0) {
perror("open hello");
exit(1);
}
p = mmap(NULL, 6, PROT_WRITE, MAP_SHARED, fd, 0);
if (p == MAP_FAILED) {
perror("mmap");
exit(1);
}
close(fd);
p[0] = 0x30313233;
munmap(p, 6);
return 0;
}在运行前后,hello文件内容:
这个是什么情况呢?求解释。。。
[ 本帖最后由 c_icer 于 2011-11-29 15:02 编辑 ]







