emscripten-core / emscripten-core/emscripten
munmap fails if file has been closed
Open
- Dominant language
- C++
- Stars
- 27.6k
- Forks
- 3.6k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 105
Description
In linux, you can do:
1) open file
2) memory map a region of the file (`mmap`)
3) close file
4) do stuff with the memory mapped region
5) `munmap` region
In emscripten, it mostly works, but munmap returns -1 if the file is closed.
test.c
```
#include
#include
#include
#include
int main()
{
int fd;
char *addr;
int result;
fd=open("test-unmap.c",O_RDONLY);
addr=mmap(NULL,64,PROT_READ,MAP_SHARED,fd,0);
close(fd);
// this call should succeed, but actually fails
result=munmap(addr,64);
printf("%d\n",result);
}
```
To reproduce:
`emcc test-unmap.c -lnodefs.js -lnoderawfs.js`
Contributor guide
Assessment
This issue has not been assessed yet.