Detailed description of fcntl functions for file control and fcntl functions for control
Abstract:This article mainly discusses the basic application of the fcntl function for file control. the dup function can copy file descriptors, while the fcntl
Refer to the differences between FCNTL (), LOCKF, flock in LinuxWhat is the difference between these three functions , which are all about locking up a file?First flock and fcntl are system calls, and LOCKF is a library function . LOCKF is actually
Function Description: describes the features of a file based on its description.File control functionsFcntl -- file control
LibraryStandard C library (libc,-LC)
Synopsis# Include ;Int fcntl (int fd, int cmd );Int fcntl (int fd, int cmd, long Arg
Function Description: Manipulate file characteristics According to the file description.File Control function FcntlHeader file:#include #include Function Prototypes:int fcntl (int fd, int cmd);int fcntl (int fd, int cmd, long arg);int fcntl (int fd,
1. DUP functionThe 1.1 DUP function is used to copy a file descriptor , and the copied file descriptor can be used normally (see Example 1). The DUP function returns one of the smallest available file descriptors in the current File descriptor table
7.2 File Lock This is a file lock for Linux and the code is downloaded in the file lock code. File locking is a very important part of a multi-user, multitasking operating system.programs often need to share data, which is usually done through a
1.dup and DUP2 functions#include int dup (int fd);int dup2 (int fd1,int fd2);Two is a description of the copy of an existing fileTwo function return: If the new file is successfully described, if the error is-1;The new file descriptor returned by
Close (close the file)
Related functions
Open, fcntl, shutdown, unlink, fclose
Header file
# Include
Define functions
Int close (int fd );
Function Description
If the file is no longer needed after
I. What is file lock? No one will be unfamiliar with the word lock, because there are a lot of locks in our lives, and they play their role in all aspects, the lock function in the world can be summarized as one sentence, that is, to prevent some
One, what is file lockFor the word lock, we must not be unfamiliar, because we live in a large number of locks, they play its role in all aspects of the world, now the function of the lock can be summed up as a sentence, is to prevent some people do
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.