Why use âlock fileâ instead of a programmable lock?
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
Mark says at https://unix.stackexchange.com/a/467795/
One use for O_EXCL and O_CREAT with open() is to create a simple lock file. If multiple processes try to open the same file with the O_CREAT and O_EXCL flags, one will succeed and the rest will fail. Of course, if the file already exists, for example because a previous process exited without removing the file, none of the subsequent attempts will succeed, so this is not the most robust way to manage a lock.
What does "lock file" mean?
The quote seems to me that the program which creates a lock file should delete it before termination. If so, is a lock file not used for storing meaning data, but for some other purpose?
It seems a lock file is used as a lock to synchronize several processes.
What is the benefits and disadvantages of using a lock file compared to using a lock in source code?
Thanks.
files io lock
add a comment |Â
up vote
0
down vote
favorite
Mark says at https://unix.stackexchange.com/a/467795/
One use for O_EXCL and O_CREAT with open() is to create a simple lock file. If multiple processes try to open the same file with the O_CREAT and O_EXCL flags, one will succeed and the rest will fail. Of course, if the file already exists, for example because a previous process exited without removing the file, none of the subsequent attempts will succeed, so this is not the most robust way to manage a lock.
What does "lock file" mean?
The quote seems to me that the program which creates a lock file should delete it before termination. If so, is a lock file not used for storing meaning data, but for some other purpose?
It seems a lock file is used as a lock to synchronize several processes.
What is the benefits and disadvantages of using a lock file compared to using a lock in source code?
Thanks.
files io lock
unix.stackexchange.com/q/143676/117549 and unix.stackexchange.com/q/12815/117549 and unix.stackexchange.com/q/22044/117549
â Jeff Schaller
8 mins ago
Possible duplicate of What are pid and lock files for?
â Jeff Schaller
8 mins ago
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
Mark says at https://unix.stackexchange.com/a/467795/
One use for O_EXCL and O_CREAT with open() is to create a simple lock file. If multiple processes try to open the same file with the O_CREAT and O_EXCL flags, one will succeed and the rest will fail. Of course, if the file already exists, for example because a previous process exited without removing the file, none of the subsequent attempts will succeed, so this is not the most robust way to manage a lock.
What does "lock file" mean?
The quote seems to me that the program which creates a lock file should delete it before termination. If so, is a lock file not used for storing meaning data, but for some other purpose?
It seems a lock file is used as a lock to synchronize several processes.
What is the benefits and disadvantages of using a lock file compared to using a lock in source code?
Thanks.
files io lock
Mark says at https://unix.stackexchange.com/a/467795/
One use for O_EXCL and O_CREAT with open() is to create a simple lock file. If multiple processes try to open the same file with the O_CREAT and O_EXCL flags, one will succeed and the rest will fail. Of course, if the file already exists, for example because a previous process exited without removing the file, none of the subsequent attempts will succeed, so this is not the most robust way to manage a lock.
What does "lock file" mean?
The quote seems to me that the program which creates a lock file should delete it before termination. If so, is a lock file not used for storing meaning data, but for some other purpose?
It seems a lock file is used as a lock to synchronize several processes.
What is the benefits and disadvantages of using a lock file compared to using a lock in source code?
Thanks.
files io lock
files io lock
edited 2 mins ago
asked 17 mins ago
Tim
24.2k67233423
24.2k67233423
unix.stackexchange.com/q/143676/117549 and unix.stackexchange.com/q/12815/117549 and unix.stackexchange.com/q/22044/117549
â Jeff Schaller
8 mins ago
Possible duplicate of What are pid and lock files for?
â Jeff Schaller
8 mins ago
add a comment |Â
unix.stackexchange.com/q/143676/117549 and unix.stackexchange.com/q/12815/117549 and unix.stackexchange.com/q/22044/117549
â Jeff Schaller
8 mins ago
Possible duplicate of What are pid and lock files for?
â Jeff Schaller
8 mins ago
unix.stackexchange.com/q/143676/117549 and unix.stackexchange.com/q/12815/117549 and unix.stackexchange.com/q/22044/117549
â Jeff Schaller
8 mins ago
unix.stackexchange.com/q/143676/117549 and unix.stackexchange.com/q/12815/117549 and unix.stackexchange.com/q/22044/117549
â Jeff Schaller
8 mins ago
Possible duplicate of What are pid and lock files for?
â Jeff Schaller
8 mins ago
Possible duplicate of What are pid and lock files for?
â Jeff Schaller
8 mins ago
add a comment |Â
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f476166%2fwhy-use-lock-file-instead-of-a-programmable-lock%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
unix.stackexchange.com/q/143676/117549 and unix.stackexchange.com/q/12815/117549 and unix.stackexchange.com/q/22044/117549
â Jeff Schaller
8 mins ago
Possible duplicate of What are pid and lock files for?
â Jeff Schaller
8 mins ago