programmer questions - MMAP

Dan Nelson dnelson at allantgroup.com
Wed Apr 5 21:43:05 UTC 2006


In the last episode (Apr 05), Wojciech Puchar said:
> the question is - why character 'a' isn't written!??!?!
> 
> #include <sys/mman.h>
> #include <fcntl.h>
> #include <stdio.h>
> #include <unistd.h>
> main() {
>  int ff=open("test",O_RDWR|O_CREAT,0666);
>  char *adr;
>  lseek(ff,1<<24,0);
>  write(ff,"",1);
>  adr=mmap(0,1<<24,PROT_READ|PROT_WRITE,MAP_NOCORE,ff,0);

Try MAP_NOCORE|MAP_SHARED here. It's probably defaulting to a private
mapping.

-- 
	Dan Nelson
	dnelson at allantgroup.com


More information about the freebsd-questions mailing list