I have a situation where I need to perform file IO but I'm sandboxed. So, I'm using shm_open with mmap, to return a file descriptor which I can happily read/write to/from in memory.
The problem I have is that a platform that I am porting to does not have shm_open. Does mmap require arg 5 to be a "file descriptor"? Or is there some other way I can use mmap without shm_open?
Thanks!
You can use the MAP_ANONYMOUS flag to just map a piece of memory. This is basically the same as calling malloc, and no data you write will be saved as it's all in memory.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With