- 论坛徽章:
- 0
|
原帖由 linux.sz 于 2008-4-8 18:30 发表 ![]()
如题所述。
如果可以,为0有没有什么特殊意义?
length为0不是没有什么意义么?
刚还专门随便写了几行代码试验了一下,gcc下编译通过,但是运行报错:
- #include <sys/mman.h>
- #include <sys/stat.h>
- #include <sys/types.h>
- #include <fcntl.h>
- #include <stdlib.h>
- #include <stdio.h>
- int main(void)
- {
- int fd;
- fd = open("text.c", O_RDWR);
- if (mmap(0, 0, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0) == (void *)-1) {
- perror("mmap");
- exit (1);
- }
- exit (0);
- }
复制代码
- ken@mylinux:~$ gcc -Wall -o test test.c
- ken@mylinux:~$ ./test
- mmap: Invalid argument
复制代码 |
|