Open
Description
When using emcc to compile wasm, I try to use mmap to write the file, but if you close fd before calling munmap, the written content will be lost.
Here is the example.
int len = string.size();
int fd = open("test-shared.txt", O_RDWR | O_CREAT, 00777);
lseek(fd, len - 1, SEEK_END);
write(fd, " ", 1);
char* buffer = (char*) mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
memcpy(buffer, string.data(), len);
// close(fd); // open it will lose all content, but it's ok in the linux environment.
munmap(buffer, len);
close(fd); // it's fine.