IO

一 、 unbuffered IO

1. file descriptor

In computer programming, a file descriptor is an abstract indicator for accessing a file. The term is generally used in POSIX operating systems . In Microsoft Windows terminology and in the context of the C standard I/O library , "file handle " is preferred, though the latter case is technically a different object (see below).

In POSIX, a file descriptor is an integer , specifically of the C type int . There are 3 standard POSIX file descriptors which presumably every process (save perhaps a daemon ) should expect to have:

Integer valueName
0Standard Input (stdin)
1Standard Output (stdout)
2Standard Error (stderr)

Generally, a file descriptor is an index for an entry in a kernel -resident data structure containing the details of all open files. In POSIX this data structure is called a file descriptor table , and each process has its own file descriptor table . The user application passes the abstract key to the kernel through a system call , and the kernel will access the file on behalf of the application, based on the key. The application itself cannot read or write the file descriptor table directly.

In Unix-like systems, file descriptors can refer to files, directories , block or character devices (also called "special files"), sockets , FIFOs (also called named pipes ), or unnamed pipes .

The FILE * file handle in the C standard I/O library routines is technically a pointer to a data structure managed by those library routines; one of those structures usually includes an actual low level file descriptor for the object in question on Unix-like systems. Since file handle refers to this additional layer, it is not interchangeable with file descriptor .

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值