logoalt Hacker News

koakuma-chanyesterday at 9:53 PM2 repliesview on HN

How do you handle read/write errors with mmap?


Replies

Falcondoryesterday at 9:59 PM

mmap on file io errors would manifest in Signals (For example SIGBUS or SIGSEGV).

So if you wanted to handle file read/write errors you would need to implement signal handlers.

https://stackoverflow.com/questions/6791415/how-do-memory-ma...

show 1 reply
icedchaiyesterday at 11:08 PM

In my experience, having worked with a large system that used almost exclusively mmap for I/O, you don’t. The process segfaults and is restarted. In practice it almost never happened.