The memory ing file in linux cannot be written back-Linux general technology-Linux programming and kernel information. The following is a detailed description. I recently switched to programming in linux. When using mmap/msync, I found that I could not write Memory changes back to the file. mmap and msync both returned 0, but the file content was not changed, later, the experiment found that the mmap parameter was incorrectly understood.
Because I didn't want to share The memory ing with other processes at The beginning, I set The MAP_PRIVATE parameter, which is called "The segment is private, changes are local "means that all the changes are visible only to this process, and other processes are invisible. To make it clear, the changes are only made in the memory space of the process, it does not affect other processes or the content of files. Therefore, it is useless to call msync.
Summary:
Error message: the memory ing file cannot be written back.
Error cause: MAP_PRIVATE is set.
Correct: Use MAP_SHARED
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service