I came across something I've never seen before in the Linux pthreads
documentation here: http://linux.die.net/man/3/pthread_mutexattr_init
What I'm referring to is the below:
int fd = open(....);
void* ptr = mmap(....);
close (fd);
return ptr;
How can ptr
still be valid if the file is closed? I was under the impression that the file has to be open throughout the life-time of the map. Then when you are ready to destroy it, you munmap
first THEN you close
..
Can someone explain why this code is valid? Does this also hold true for windows?