If I reboot windows while a third-party process has a file locked, will the lock be automatically released?

1

If I reboot windows while a third-party process has a file locked, will the lock be automatically released?

By third-party, I mean any non-windows process, such as my software or another vendors software.

If so, is it 100% or depends?

The Coordinator

Posted 2015-05-22T21:54:54.890

Reputation: 161

Can you define 3rd party? Something accessing it via the network? – Jarmund – 2015-05-22T21:57:00.247

The process will be shutdown before windows restarts so, yeah, the file lock is released – Ramhound – 2015-05-22T22:32:11.267

Locks are held in memory while the OS is running, not by flagging the files on disk in any way. So all locks owned nyba process are automatically released when that process quits. – Colin 't Hart – 2015-05-23T07:27:50.187

@Colin'tHart so, if computer A has a file locked on remote computer B's drive, and I pull the plug (power outage) on A, when will the lock on B's drive be released? – The Coordinator – 2015-05-23T09:07:10.937

@Colin'tHart File locking on Windows goes all the way back to this, and is still compatible with this: http://www.vfrazee.com/ms-dos/6.22/help/share.htm

– The Coordinator – 2015-05-23T09:11:57.263

Answers

2

Yes. Windows gives each program WaitToKillAppTimeout seconds to shutdown (default is 20): https://technet.microsoft.com/en-us/library/cc978624.aspx

After it, it closes all programs. All files are released, file handlers become invalid and Windows shuts down.

user996142

Posted 2015-05-22T21:54:54.890

Reputation: 1 205

1

First of all, yes, as per the answer provided by @user996142

To elaborate on my comment regarding network processes, the answer is "eventually, yes". Anything accessing your files via the network is actually locking the file indirectly. The host process on your machine (for example, whatever process is behind the SMB sharing) does the actual file locking. If something is accessing this file, and you force a hibernate or suspend, when you resume it will still be locked until the SMB process notices that the client is not connected anymore, and release the lock. I am not sure of the timeframe here, but microsoft seems to like timeout defaults of 2 minutes.

Jarmund

Posted 2015-05-22T21:54:54.890

Reputation: 5 155