Locking Executing Files: Windows does, Linux doesn't. Why?

前端 未结 8 1445
有刺的猬
有刺的猬 2020-12-04 09:18

I noticed when a file is executed on Windows (.exe or .dll), it is locked and cannot be deleted, moved or modified.

Linux, on the other hand, does not lock executing

相关标签:
8条回答
  • 2020-12-04 10:19

    I think you're too absolute about Windows. Normally, it doesn't allocate swap space for the code part of an executable. Instead, it keeps a lock on the excutable & DLLs. If discarded code pages are needed again, they're simply reloaded. But with /SWAPRUN, these pages are kept in swap. This is used for executables on CD or network drives. Hence, windows doesn't need to lock these files.

    For .NET, look at Shadow Copy.

    0 讨论(0)
  • 2020-12-04 10:24

    As far as I know, linux does lock executables when they're running -- however, it locks the inode. This means that you can delete the "file" but the inode is still on the filesystem, untouched and all you really deleted is a link.

    Unix programs use this way of thinking about the filesystem all the time, create a temporary file, open it, delete the name. Your file still exists but the name is freed up for others to use and no one else can see it.

    0 讨论(0)
提交回复
热议问题