I get a lock file like this, but don't know what does it do?

1

when I open a file , and the program creates this file, what does this lock file do ? is it a prevention from simultaneous run ?

<?xml version="1.0" encoding="UTF-8"?>
    <LockFile>
      <CreationData>
        <Data AccessMode="w"/>
        <Data Host="VAIO"/>
        <Data Process="56496"/>
        <Data Time="05/02/2016 23:59:03"/>
        <Data User="ddd"/>
      </CreationData>
    </LockFile>

Farzad64

Posted 2016-02-06T08:28:02.333

Reputation: 163

I have put also the contents of the .lockfile, but why arent they visible here ?! – Farzad64 – 2016-02-06T08:39:26.830

Answers

2

Lock files are used to prevent Race Conditions, a situation that occurs when two processes that share/change the same resources run at the same time and can cause unexpected effects.

Programs will implement lock files in their own way, which usually will prevent you from running or opening a second instance of the file, or forces the second instance to be in a read only mode to prevent both instances altering the source.

Most Microsoft Office files create a hidden lock file in the same location of the source file (unless the file is set up for sharing), and will cause a message to show as follows:

enter image description here

enter image description here

These options allow you to open a file as read only, or to show a message once the lock file has been removed.

The program itself will implement and handle lock files in it's own way, so the behaviour, although typically like this, may implement different methods of handling lock files.

More information: File Locking, Lock (Computer Science) and, to some extent, Mutual Exclusion (Mutex)

Jonno

Posted 2016-02-06T08:28:02.333

Reputation: 18 756

thank you so much , shall I ask , in which file types , I can file the lock file creation ? – Farzad64 – 2016-02-06T08:37:43.413

1@Farzad64 There is no specific format or standard, it's up to the program itself. For Microsoft office, it'll be a hidden file prefixed with "~$" as per my image. It's impossible to say for anything else, they could be .lock files, it may not even be a file but a database somewhere. – Jonno – 2016-02-06T08:39:50.180

so it's mostly hidden ? and it's programming language could be any ? – Farzad64 – 2016-02-06T08:40:39.477

1@Farzad64 It's entirely up to the developer. Your post shows a file of XML format, storing some basic information to validate the lock itself. It could literally be an empty file with any name, in any location. It's up to the developer. – Jonno – 2016-02-06T08:41:40.413