简体   繁体   English

如果进程是SIGKILLed,OS(POSIX)是否刷新内存映射文件?

[英]Does the OS (POSIX) flush a memory-mapped file if the process is SIGKILLed?

If a process is killed with SIGKILL, will the changes it has made to a memory-mapped file be flushed to disk? 如果使用SIGKILL终止进程,它对内存映射文件所做的更改是否会刷新到磁盘? I assume that if the OS ensures a memory-mapped file is flushed to disk when the process is killed via SIGKILL, then it will also do so with other terminating signals (SIGABRT, SIGSEGV, etc...). 我假设如果操作系统确保在通过SIGKILL终止进程时将内存映射文件刷新到磁盘,那么它也将使用其他终止信号(SIGABRT,SIGSEGV等等)执行此操作。

It will depend on whether the memory-mapped file is opened with modifications private (MAP_PRIVATE) or not (MAP_SHARED). 它取决于是否使用private(MAP_PRIVATE)修改(MAP_SHARED)打开内存映射文件。 If private, then no; 如果私有,那么没有; the modifications will not be written back to disk. 修改不会写回磁盘。 If shared, the kernel buffer pool contains the modified buffers, and these will be written to disk in due course - regardless of the cause of death. 如果共享,则内核缓冲池包含已修改的缓冲区,并且这些缓冲池将在适当的时候写入磁盘 - 无论死亡原因如何。

I posed a similar question myself and then followed up with demonstration code when I was unsatisfied with the answers. 我自己提出了一个类似的问题,然后在我对答案不满意时跟进了演示代码。 See mmap, msync and linux process termination 请参阅mmap,msync和linux进程终止

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM