current position:Home>Linux system programming 43 file descriptor

Linux system programming 43 file descriptor

2022-02-04 16:38:11 sinat_ thirty-six million seventy thousand four hundred and eig

 

gcc The default generated executable is a.out file  

PCB Process control block / Process descriptors

Essence is a structure , One of the members is a pointer , Pointer to file descriptor table .

File descriptors are stored in the file descriptor table . In essence, the file descriptor table stores pointers . If you're pulling down , In fact, it is the mapping corresponding to the key value .fd What is returned is the index of the array .

  The operating system doesn't want you to know him , I don't want you to study it , So the specific implementation details will be hidden from you .( A little bit like cpp Information concealment ).

A process can open up to 1024 File .

The file descriptor table also follows such a principle : The newly opened file descriptor must be the smallest one available . The standard input , standard output Standard error Although the file descriptor is 0 1 2 , But when not recommended , Use these three numbers directly , Instead, use the corresponding macro .STDIN_FILENO STDOUT_FILENO STDERR_FILENO.

copyright notice
author[sinat_ thirty-six million seventy thousand four hundred and eig],Please bring the original link to reprint, thank you.
https://en.cdmana.com/2022/02/202202041638094883.html

Random recommended