Don't bother writing a terminating null to the mapped page.
Since we mmap length st_size + 1, and since mmap(2) fills the mapped page past the length of the file with nulls, we ensure that there is a terminating null after the file contents. This means that the file can be opened with O_RDONLY and mmap'd with PROT_READ. So the child process only needs read permissions on the file. Pointed out by Nils
Showing
Please register or sign in to comment