Linux recommended lock and Force lock

Source: Internet
Author: User

as a Apue 14.3 references to sections

linux There is a forced lock Span style= "Font-family:verdana; Background-color: #fafbfc "", but not enabled by default want to let linux support for mandatory locks, not only in mount need to add -o mand, and you need to set permissions on the files you want to lock.

1 , ?????????????? recommended lock also known as cooperative lock. For this type of lock, the kernel simply provides a lock-and-lock operation, but does not provide lock control and coordination. In other words, if an application is working on a file, it does not detect whether to lock or ignore the lock and write data directly to the file, the kernel does not block control. Therefore, the proposed lock, can not prevent the process of the file operation, but only rely on people consciously to detect whether to lock and then constrain their behavior;

2 , ?????????????? Force lock, is os kernel file lock. For each action on a file, for example, execute open , read write os Internally detects if the file has been forced to lock, and if the lock causes these file operations to fail. That is, the kernel enforces the application to comply with the rules of the game;

2 , ?????????????? by fork The resulting child process does not inherit the locks set by the parent process. means that if a process gets a lock and then calls fork fcntl

3 , ?????????????? exec close-on-exec flag, So when you close the file descriptor as part of exec !!

this article from CSDN Blog, reproduced please indicate the source: http://blog.csdn.net/jiang1013nan/archive/2010/07/08/5721675.aspx

By default Ubuntu 14.04 It is true that no forced lock is turned on. , Use Apue The program that comes with it is verified.

Linux recommended lock and Force lock

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.