The system calls DUP and dup2 to copy the file descriptor. The DUP returns a new file descriptor (the smallest number that is not used by the file descriptor). Dup2 can let the user specify the value of the returned file descriptor, and, if
1. File descriptor in the kernel data structureBefore I go into specific dup/dup2, I think it's necessary to look at the file descriptor's pattern in the kernel. During the existence of a process, some files will be opened, which will return some
Image Understanding dup and dup2 functions-general Linux technology-Linux programming and kernel information. The following is a detailed description. I believe that most programmers programming in Unix/Linux have the "APUE in Unix environment"
the role of DUP and dup2DUP and dup2 are also two very useful calls that are used to copy the descriptor of a file. They are often used to redirect stdin, stdout, and stderr of processes. The prototypes for these two functions are as
I believe that most programmers programming in Unix/Linux have the "apue in UNIX environment" Super classic masterpiece. In this book, the author explains DUP/dup2 previously mentioned "file sharing", which is helpful for understanding DUP/dup2.
I. Files in Linux
There are four types of files: common files, directory files, link files, and device files.
1. Common files
Is the most commonly used file, including text files, shell scripts, binary executable and various types of data.
Ls-LH
Http://www.xxlinux.com/linux/article/development/soft/20090828/17508.html
I believe that most programming in Unix/LinuxProgramThey all have the Super classic masterpiece apue. In this book, the author explains DUP/dup2 previously mentioned
DUP and dup2 are two very useful calls. They are used to copy the descriptor of a file. They are often used to redirect stdin, stdout, and stderr of processes. The original form of these two functions is as follows: # include int DUP (INT oldfd);
(1) Each process has a record item in the Process Table. Each record item contains an open file descriptor table, which can be considered as a vector, and each descriptor occupies one item. Associated with each file descriptor is:(A) file descriptor
Transferred from: http://eriol.iteye.com/blog/1180624Transferred from: http://www.cnblogs.com/jht/archive/2006/04/04/366086.htmlDUP and dup2 are also two very useful calls that are used to copy the descriptor of a file. They are often used to
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.