i.t品牌什么档次| 什么鱼红烧最好吃| 政法委是干什么的| 鬼子红药店里叫什么药| 黄精和什么煲汤好| 蜂胶是什么| 硬气是什么意思| 珍珠鸟吃什么食物| 电灯泡什么意思| 维生素e和维生素c一起吃有什么效果| 胎毛什么时候脱落| 射手座属于什么象星座| 今年是什么年天干地支| 红眼鱼是什么鱼| 多巴胺高是什么原因| 睡多了头疼是什么原因| 长孙是什么意思| ddg是什么意思| 吃什么提高免疫力| 白细胞高吃什么降得快| 调理是什么意思| mechrevo是什么牌子的电脑| 常吃南瓜子有什么好处和坏处| 半夏反什么药| 什么动物有三个心脏| 茶学专业学什么| 什么人容易得心理疾病| 家里为什么会进蝙蝠| 登对是什么意思| 儿童发育过早应该挂什么科| 回肠荡气什么意思| 开火车什么意思| 为什么早上起来口苦| 梦见吐痰是什么意思| pc是什么单位| 翡翠属于什么五行| 吃什么食品减肥| 为什么会甲状腺肿大| 小鸟进屋有什么预兆吗| 马蜂窝能治什么病| 短裙配什么鞋子好看| 气管炎咳嗽吃什么药最有效| 支气管炎吃什么药最好| 可望不可求是什么意思| 4b橡皮和2b橡皮有什么区别| 老是做噩梦是什么原因| zoom什么意思| 优势是什么意思| 很多屁放是什么原因| 100年前是什么朝代| 胃阴虚吃什么中成药| 蛇遇猪就得哭什么意思| 大姨妈期间吃什么好| 偏光眼镜是什么意思| 打摆子是什么病| 城镇户口是什么意思| 什么是木薯| arg是什么氨基酸| ft是什么| 治字五行属什么| 假性宫缩是什么感觉| 食欲亢进是什么意思| 淋巴结有血流信号预示着什么| 眼皮跳是什么原因| 心律不齐是什么原因引起的| 炖羊肉都放什么调料| 为什么运动完会恶心头晕想吐| 黄帝内经是什么时期的| 傻白甜的意思是什么| 4月6号什么星座| 什么是再生障碍性贫血| 钾低会出现什么症状| 大电念什么| 19属什么| 李子有什么功效与作用| 吃榴莲不能吃什么东西| 头发偏黄是什么原因| 香榧是什么| 筠字五行属什么| 籺是什么意思| 为什么瘦不下来| 特步属于什么档次| 孕妇建档需要检查什么| 双子座是什么时候| alike是什么意思| 鲨鱼是什么动物| 煤气是什么味道| 什么样人穿棉麻好看| 急性肠胃炎用什么药| 夏天适合养什么花| 肺炎吃什么药有效| 矫正视力是指什么| 什么是再生纤维素纤维| 母亲节送给妈妈什么礼物| 宝宝病毒性感冒吃什么药效果好| 狼藉是什么意思| 丑是什么意思| 甘油三酯吃什么药| 96120是什么电话| 风湿热是什么病| 做b超前需要注意什么| 肺部硬结灶是什么意思| 什么狗不咬人| 血半念什么| 莆田医院是什么意思| 水牛是什么意思| 梦见烧火是什么意思| 小巴西龟吃什么食物| 千呼万唤是什么生肖| 热伤风流鼻涕吃什么药| 水猴子是什么动物| classy是什么意思| 有什么赚钱的软件| ko是什么意思啊| 劳改是什么意思| 单丛属于什么茶| evisu是什么牌子| 股票pe是什么意思| fmp是什么意思| 12点半是什么时辰| 婴儿腹泻吃什么好| 最好的烟是什么牌子| 叶公好龙的好是什么意思| 女性看乳房应该挂什么科| 冰箱发烫是什么原因| 健康证都查什么| 早上吃什么| 道德经适合什么人看| 猛吸气胸口疼什么原因| 什么的草地| 梦见蝴蝶是什么意思| 反复口腔溃疡是什么原因| iu什么意思| 咳嗽吃什么食物好得快| 鸟对什么| 为什么不吃猪肉| otc是什么意思| hope是什么意思啊| 手足口病忌口什么食物| 头发是什么组织| 6月18日什么星座| 胃酸烧心吃什么药可以根治| 闻思修是什么意思| 大连焖子是什么做的| 破瓦法是什么| 肝胆湿热吃什么中成药| 医生是什么生肖| 农历12月26日是什么星座| 炀是什么意思| 腱鞘囊肿是什么原因引起的| 神昏谵语是什么意思| 羊汤放什么调料| 放屁多吃什么药好| 为什么眼睛会痛| 稳是什么意思| 红色加黄色是什么颜色| 嚼舌根是什么意思| 腿抖是什么病的预兆| 专长是什么意思| 朋友是什么| 羽下面隹什么字| 消防大队长是什么级别| 春天都开什么花| 血热吃什么好| 湿疹擦什么药膏| 月经期间可以喝什么汤比较好| 浅表性胃炎什么症状| 1997年属牛的是什么命| 三什么开泰| 尿潜血挂什么科| 神经官能症挂什么科| 陈赫为什么离婚| 1987属什么生肖| 沙特用什么货币| 狐臭的味道像什么味道| im是什么| 诗五行属性是什么| 甘油脂肪酸酯是什么| 扁桃体发炎是什么症状| 大饼脸适合什么发型| 梦见煤气罐爆炸是什么意思| 假体是什么| 用什么洗头白发能变黑| 吃什么补气血效果最好| 轻度抑郁症吃什么药| 虎属什么五行| 卫生间除臭用什么最好| hpv是什么意思啊| dpm是什么意思| 中国肤药膏有什么功效| 宫颈口大是什么原因| 鲜为人知什么意思| 梦见种菜是什么意思| 不什么下什么的成语| 面瘫是什么原因造成的| 72岁属什么生肖| 白砂糖和冰糖有什么区别| 眼皮有点肿是什么原因| 小孩子肚子痛吃什么药| 黄痰是什么原因造成的| 9月三号是什么日子| 手冲是什么意思| 葡萄糖高是什么意思| 女人喜欢什么样的男人| 大人吃什么排黄疸快| 尿路感染需要做什么检查| 什么叫布施| 避孕药有什么副作用| 2025年是什么命| 什么原因引起甲亢| 亥是什么意思| 缺钾吃什么补得最快| 狗为什么不能吃葡萄| 尿蛋白2加是什么意思| 什么中药治肝病最好| 女生喝什么茶好| 兔子不吃窝边草是什么意思| 黄柏胶囊主要治什么病| 风起云涌是什么意思| 分分钟都妙不可言是什么歌| 液基细胞学检查是什么| 孩子生化了是什么意思| 为什么会有甲状腺结节| 麻油跟香油什么区别| 莺莺燕燕是什么意思| barbie是什么意思| 有始无终是什么生肖| 婴儿为什么喜欢趴着睡| 什么人容易得尿毒症| 甲减是什么原因引起的| 洁白丸治什么类型胃病| 手背肿是什么原因| 字母圈是什么意思| 什么是童子命| e抗体阳性说明什么| 白扁豆长什么样| 男性湿热吃什么药最好| 紫癜吃什么好得快| 高血压不能吃什么食物| 此地无银三百两是什么意思| 中国最好的大学是什么大学| 阴阳数字是什么数| 多吃什么可以长头发| 感冒咳嗽吃什么药| 酸枣仁配什么治疗失眠| 鸡米头是什么| 胃动力不足是什么原因造成的| 兰花什么时候开| 痹病是什么意思| 瘆人是什么意思| 总是放屁什么原因| 甲硝唑的副作用是什么| 自由基是什么| 金骏眉属于什么茶类| 拔完智齿吃什么食物好| 缺碘吃什么| 增强ct是什么意思| 瑄字五行属什么| 清秋是什么意思| 为什么做梦| 活泼开朗是什么意思| 黑管是什么乐器| 妄语是什么意思| hpv53阳性是什么意思| 百度

电视剧《白鹿原》是否会火 三大看点揭秘白鹿精魂

百度     “这位妈妈的初衷是关爱孩子,可当自己知道因此导致孩子患上精神障碍时无法接受。

In Unix and Unix-like computer operating systems, a file descriptor (FD, less frequently fildes) is a process-unique identifier (handle) for a file or other input/output resource, such as a pipe or network socket.

File descriptors typically have non-negative integer values, with negative values being reserved to indicate "no value" or error conditions.

File descriptors are a part of the POSIX API. Each Unix process (except perhaps daemons) should have three standard POSIX file descriptors, corresponding to the three standard streams:

Integer value Name <unistd.h> symbolic constant[1] <stdio.h> file stream[2]
0 Standard input STDIN_FILENO stdin
1 Standard output STDOUT_FILENO stdout
2 Standard error STDERR_FILENO stderr

Overview

edit
 
File descriptors for a single process, file table and inode table. Note that multiple file descriptors can refer to the same file table entry (e.g., as a result of the dup system call[3]:?104?) and that multiple file table entries can in turn refer to the same inode (if it has been opened multiple times; the table is still simplified because it represents inodes by file names, even though an inode can have multiple names). File descriptor 3 does not refer to anything in the file table, signifying that it has been closed.

In the traditional implementation of Unix, file descriptors index into a per-process file descriptor table maintained by the kernel, that in turn indexes into a system-wide table of files opened by all processes, called the file table. This table records the mode with which the file (or other resource) has been opened: for reading, writing, appending, and possibly other modes. It also indexes into a third table called the inode table that describes the actual underlying files.[3] To perform input or output, the process passes the file descriptor to the kernel through a system call, and the kernel will access the file on behalf of the process. The process does not have direct access to the file or inode tables.

On Linux, the set of file descriptors open in a process can be accessed under the path /proc/PID/fd/, where PID is the process identifier. File descriptor /proc/PID/fd/0 is stdin, /proc/PID/fd/1 is stdout, and /proc/PID/fd/2 is stderr. As a shortcut to these, any running process can also access its own file descriptors through the folders /proc/self/fd and /dev/fd.[4]

In Unix-like systems, file descriptors can refer to any Unix file type named in a file system. As well as regular files, this includes directories, block and character devices (also called "special files"), Unix domain sockets, and named pipes. File descriptors can also refer to other objects that do not normally exist in the file system, such as anonymous pipes and network sockets.

The FILE data structure in the C standard I/O library usually includes a low level file descriptor for the object in question on Unix-like systems. The overall data structure provides additional abstraction and is instead known as a file handle.

Operations on file descriptors

edit

The following lists typical operations on file descriptors on modern Unix-like systems. Most of these functions are declared in the <unistd.h> header, but some are in the <fcntl.h> header instead.

Creating file descriptors

edit
  • open()
  • creat()[5]
  • socket()
  • accept()
  • socketpair()
  • pipe()
  • epoll_create() (Linux)
  • signalfd() (Linux)
  • eventfd() (Linux)
  • timerfd_create() (Linux)
  • memfd_create() (Linux)
  • userfaultfd() (Linux)
  • fanotify_init() (Linux)
  • inotify_init() (Linux)
  • clone() (with flag CLONE_PIDFD, Linux)
  • pidfd_open() (Linux)
  • open_by_handle_at() (Linux)
  • kqueue() (BSD)
  • pdfork() (kFreeBSD)

Deriving file descriptors

edit
  • dirfd()
  • fileno()

Operations on a single file descriptor

edit
  • read(), write()
  • readv(), writev()
  • pread(), pwrite()
  • recv(), send()
  • recvfrom(), sendto()
  • recvmsg(), sendmsg() (also used for sending FDs to other processes over a Unix domain socket)
  • recvmmsg(), sendmmsg()
  • lseek(), llseek()
  • fstat()
  • fstatvfs()
  • fchmod()
  • fchown()
  • ftruncate()
  • fsync()
  • fdatasync()
  • fdopendir()
  • fgetxattr(), fsetxattr() (Linux)
  • flistxattr(), fremovexattr() (Linux)
  • statx (Linux)
  • setns (Linux)
  • vmsplice() (Linux)
  • pidfd_send_signal() (Linux)
  • pdkill() (kFreeBSD)
  • waitid() (with P_PIDFD ID type, Linux)
  • fdopen() (stdio function:converts file descriptor to FILE*)
  • dprintf() (stdio function: prints to file descriptor)

Operations on multiple file descriptors

edit
  • select(), pselect()
  • poll(), ppoll()
  • epoll_wait(), epoll_pwait(), epoll_pwait2() (Linux, takes a single epoll filedescriptor to wait on many other file descriptors)
  • epoll_ctl() (for Linux)
  • kqueue() (for BSD-based systems).
  • sendfile()
  • splice(), tee() (for Linux)
  • copy_file_range() (for Linux)

Operations on the file descriptor table

edit

The fcntl() function is used to perform various operations on a file descriptor, depending on the command argument passed to it. There are commands to get and set attributes associated with a file descriptor, including F_GETFD, F_SETFD, F_GETFL and F_SETFL.

  • close()
  • closefrom() (BSD and Solaris only; deletes all file descriptors greater than or equal to specified number)
  • close_range() (for Linux)[6]
  • dup() (duplicates an existing file descriptor guaranteeing to be the lowest number available file descriptor)
  • dup2(), dup3() (Close fd1 if necessary, and make file descriptor fd1 point to the open file of fd2)
  • fcntl (F_DUPFD)

Operations that modify process state

edit
  • fchdir() (sets the process's current working directory based on a directory file descriptor)
  • mmap() (maps ranges of a file into the process's address space)

File locking

edit
  • flock()
  • fcntl() (F_GETLK, F_SETLK and F_SETLKW)
  • lockf()

Sockets

edit
  • connect()
  • bind()
  • listen()
  • accept() (creates a new file descriptor for an incoming connection)
  • getsockname()
  • getpeername()
  • getsockopt()
  • setsockopt()
  • shutdown() (shuts down one or both halves of a full duplex connection)

Miscellaneous

edit
  • ioctl() (a large collection of miscellaneous operations on a single file descriptor, often associated with a device)

at suffix operations

edit

A series of new operations has been added to many modern Unix-like systems, as well as numerous C libraries, to be standardized in a future version of POSIX.[7] The at suffix signifies that the function takes an additional first argument supplying a file descriptor from which relative paths are resolved, the forms lacking the at suffix thus becoming equivalent to passing a file descriptor corresponding to the current working directory. The purpose of these new operations is to defend against a certain class of TOCTOU attacks.

  • openat()
  • faccessat()
  • fchmodat()
  • fchownat()
  • fstatat()
  • futimesat()
  • linkat()
  • mkdirat()
  • mknodat()
  • readlinkat()
  • renameat()
  • symlinkat()
  • unlinkat()
  • mkfifoat()
  • fdopendir()

File descriptors as capabilities

edit

Unix file descriptors behave in many ways as capabilities. They can be passed between processes across Unix domain sockets using the sendmsg() system call. Note, however, that what is actually passed is a reference to an "open file description" that has mutable state (the file offset, and the file status and access flags). This complicates the secure use of file descriptors as capabilities, since when programs share access to the same open file description, they can interfere with each other's use of it by changing its offset or whether it is blocking or non-blocking, for example.[8][9] In operating systems that are specifically designed as capability systems, there is very rarely any mutable state associated with a capability itself.

A Unix process' file descriptor table is an example of a C-list.

See also

edit

References

edit
  1. ^ The Open Group. "The Open Group Base Specifications Issue 7, IEEE Std 1003.1-2008, 2016 Edition". Retrieved 2025-08-06.
  2. ^ The Open Group. "The Open Group Base Specifications Issue 7, IEEE Std 1003.1-2008, 2016 Edition". <stdio.h>. Retrieved 2025-08-06.
  3. ^ a b Bach, Maurice J. (1986). The Design of the UNIX Operating System (8 ed.). Prentice-Hall. pp. 92–96. ISBN 9780132017992.
  4. ^ "Devices - What does the output of 'll /Proc/Self/Fd/' (From 'll /Dev/Fd') mean?".
  5. ^ The Open Group. "The Open Group Base Specifications Issue 7, IEEE Std 1003.1-2008, 2018 Edition – creat". Retrieved 2025-08-06.
  6. ^ Stephen Kitt, Michael Kerrisk. "close_range(2) — Linux manual page". Retrieved 2025-08-06.
  7. ^ Extended API Set, Part 2. The Open Group. October 2006. ISBN 1931624674.
  8. ^ Brinkmann, Marcus (2025-08-06). "Building a bridge: library API's and file descriptors?". cap-talk. Archived from the original on 2025-08-06. Retrieved 2025-08-06.
  9. ^ de Boyne Pollard, Jonathan (2007). "Don't set shared file descriptors to non-blocking I/O mode". Retrieved 2025-08-06.
扁桃体发炎吃什么药比较好 蚰蜒吃什么 蚊香是什么做的 什么是风寒感冒 什么是集合
拉屎为什么是黑色的 黄药是什么 李五行属性是什么 前列腺炎吃什么药最有效 没有美瞳护理液用什么代替
热伤风吃什么药 什么月披星 婴儿流口水是什么原因引起的 睡醒口干口苦是什么原因 疱疹性咽峡炎吃什么药
尿道感染用什么消炎药 痛风吃什么中药 梦见刨红薯是什么意思 氯雷他定片治什么病 为什么会高血压
一什么杏子hcv8jop4ns4r.cn 身在其位必谋其职是什么意思hcv8jop8ns1r.cn 乡试第一名叫什么hcv9jop5ns9r.cn 查血糖挂什么科hcv8jop0ns5r.cn 米醋是什么luyiluode.com
北京五行属什么hcv8jop5ns0r.cn 婴儿肥是什么意思hcv8jop8ns8r.cn 情人眼里出西施是什么心理效应hcv7jop7ns1r.cn 右肺上叶结节什么意思hcv8jop2ns5r.cn 煤气是什么味道luyiluode.com
为什么不建议割鼻息肉hcv7jop9ns1r.cn 萎缩性胃炎用什么药最好hcv8jop9ns5r.cn 西五行属什么hcv9jop3ns7r.cn 崽崽是什么意思hcv8jop8ns0r.cn 挂彩是什么意思hcv8jop9ns8r.cn
打喷嚏流鼻涕吃什么药hcv8jop4ns2r.cn 盗汗是什么hcv9jop3ns4r.cn 电话正在通话中是什么意思hcv9jop3ns8r.cn 格桑花什么时候开花hcv9jop4ns5r.cn 运费险是什么意思hcv9jop4ns8r.cn
百度