Dear all,
I was trying to implement some code samples found in R.Stevens's bible. I
need some memory shared between parent and a child, and was hoping to get
away with mmap(), using either MAP_ANON flag or using open file handle
/dev/zero.
There is a piece of code ( I'm omitting any error control):
{
int file;
caddr_t pvAllocation;
file = open( "/dev/zero",
O_RDWR);
pvAllocation = mmap( 0,
cbAllocationSize,
PROT_READ | PROT_WRITE,
MAP_SHARED,
file,
0);
pvAllocation = mmap( 0,
cbAllocationSize,
PROT_READ | PROT_WRITE,
MAP_SHARED | MAP_ANON,
-1,
0);
close( file);
In both cases pvAllocation is returned as -1, and errno is set no EINVALQuote:}
0x16).
file gets a valid descriptor number.
Any help will be highly appreciated.
Thank you,
Ilya