文科女生学什么专业好| 蛋白粉什么时候喝| 嘴唇发麻什么病兆| 孑孓什么意思| 咳黄痰吃什么药| 减肥吃什么油| 腰肌劳损是什么意思| 定性是什么意思| 肖战是什么星座| 泡茶用什么水好| 快乐的反义词是什么| 儿童内热吃什么去内热| 无纺布是什么| 女人更年期吃什么药调理最好| 义字少一点念什么| 女人消瘦应该检查什么| 咳嗽能吃什么食物| 前列腺炎吃什么药好| 玖姿女装属于什么档次| 什么茶女人长期喝最好| 18罗汉都叫什么名字| 冒冷汗是什么原因| 颈部淋巴结挂什么科| 三七粉什么人不适合吃| 脚后跟疼是什么原因| 梦见别人拉屎是什么意思| 尿酸高可以吃什么鱼| 为什么晚上不能倒垃圾| 出国旅游需要什么手续和证件| 思前想后是什么意思| 眼白有黄斑是什么原因| 怀孕吃什么好| 恩赐是什么意思| 花心大萝卜是什么意思| 下半年有什么节日| 慰安妇是什么| 周杰伦为什么叫jay| 什么叫台风| 女性虚火旺吃什么下火| 掉头发吃什么药最有效| 顺理成章是什么意思| 根的作用是什么| 备孕需要做什么准备| 油边是什么肉| 鸟加衣念什么| 伏天从什么时候开始| 丙酮是什么| 头皮屑多是什么原因怎么去除| 儿童经常头晕什么原因导致的| 霉菌性阴道炎用什么栓剂| 汉城为什么改名叫首尔| 内心独白什么意思| 怀孕初期需要补充什么营养| 马杀鸡是什么意思| 胎膜早破是什么原因引起的| 小孩老咳嗽是什么原因| 天气热吃什么解暑| 头发晕是什么病的征兆| 总放屁还特别臭是什么原因| 宸字属于五行属什么| 中药天龙又叫什么| 列席是什么意思| ipa啤酒是指什么| 金蝉什么时候出土| 吃什么解辣最快方法| 肛塞是什么| 尿酸高什么原因| meshor是什么牌子的手表| 和女生聊天聊什么| En什么意思| 大头鱼是什么鱼| 梦见牛是什么意思| 肌酐低是什么问题| 23333是什么意思| 输血前常规检查是什么| 昏厥是什么意思| 结婚要准备什么| 血脂高有什么危害| 胆量是什么意思| 在于是什么意思| 治未病科是看什么病的| 榴莲不可以和什么食物一起吃| 尿道口下裂是什么样子| 棕色眼睛的人什么血统| 祈祷什么意思| 跑马是什么意思| 嗅觉失灵是什么原因| 吃番茄有什么好处| 吐舌头是什么意思| 掉头发是什么原因| 布洛芬什么时候吃| pct偏高说明什么| 咸肉烧什么好吃| 过敏性鼻炎吃什么中药| 膝超伸是什么| 鹰头皮带是什么牌子| 马云属什么| 情投意合是什么意思| 正剧是什么意思| 中度贫血吃什么补血快| 鸡炖什么补气血| 杨梅什么时候成熟| 小拇指和无名指发麻是什么原因| 黄芪可以和什么一起泡水喝| fs是什么单位| 十八大什么时候召开的| 黄鼻涕是什么原因| 客厅挂钟放在什么位置好| 因什么制宜| 什么地回答| 5.16号是什么星座| 六月初四是什么星座| 鲍鱼长什么样| 核磁共振是检查什么的| 爱新觉罗是什么民族| 腰椎管狭窄吃什么药| 山药炖什么好吃| 鬼斧神工是什么意思| 医院面试一般会问什么| 大葱炒什么好吃| 医院康复科是干什么的| 喉咙干咳吃什么药| 痹症是什么病| 独活主治什么病| 普瑞巴林胶囊治什么病| hi是什么| 去痘印用什么药膏| 黄瓜和什么一起炒好吃| 悲欢离合是什么意思| zqsg是什么意思| 腐竹是什么做的| 小孩黄疸高有什么危害| 蔚蓝是什么意思| 油炸食品用什么油最好| 为什么有胎记| 发痧是什么原因造成的| 滴虫性阴道炎吃什么药| 茯苓生长在什么地方| 爆竹声中一岁除下一句是什么| 利口酒是什么酒| 鱼油有什么功效| 白细胞低是什么意思| 树懒是什么动物| 生肖鸡和什么生肖最配| 甲状腺属于什么科| 宝贝什么意思| 什么是催眠| 解表是什么意思| 为什么肚子会隐隐作痛| 经期不能吃什么水果| 男人有霉菌是什么症状| 减肥喝什么茶最好最快| 正官正印是什么意思| 考试紧张吃什么药可缓解| 产假从什么时候开始算| 包茎是什么| 舌苔发黄是什么症状| 鸟加衣念什么| 骏五行属什么| 代偿是什么意思| 下加一笔是什么字| 鼻炎吃什么消炎药| 神经内科主要看什么| 969368是什么电话| 为什么不建议打水光针| 老公的姐姐叫什么| r0lex是什么牌子手表| 什么动物眼睛是红色的| 血小板低吃什么好| 乳头发黑是什么原因| 少量盆腔积液是什么意思| 嗓子嘶哑吃什么药| 地中海贫血是什么病| 屁是什么气体| 黑曜石属于五行属什么| 心衰竭是什么症状| 脚上有青筋是什么原因| 铁蛋白是查什么的| 向心性肥胖是什么意思| 手脚麻木挂什么科| 负利率是什么意思| 什么酒不能喝| 孕吐反应什么时候开始| 烫伤起泡用什么药膏| 吃马齿菜有什么好处| 心里害怕紧张恐惧是什么症状| 尿素是什么肥料| mophie是什么牌子| 哪吒代表什么生肖| 七年是什么婚| 梅毒有什么症状| 不含而立是什么意思| 膝盖发软无力是什么原因| 眼前的苟且是什么意思| 发炎是什么原因引起的| 十万个为什么儿童版| vp是什么| 1893年是什么年| 耳蜗是什么东西| 宫颈糜烂有什么症状| 苏州机场叫什么名字| 霉菌性阴道炎是什么| 包皮脱皮是什么原因| 常喝枸杞泡水有什么好处| 轻歌曼舞是什么意思| spa是什么| 六月二七是什么星座| 手脚冰凉吃什么药| 头疼呕吐吃什么药| mn是什么单位| 626什么星座| 灵芝不能和什么一起吃| 2月24日什么星座| 属兔的和什么属相最配| 髓母细胞瘤是什么病| 房颤有什么危害| 省委副书记什么级别| 男性性功能减退吃什么药| 什么海没有边| 什么是睡眠障碍| 经信委是干什么的| 绝症是什么意思| 淋巴结什么原因引起的| 今年为什么这么热| faye是什么意思| 猪大肠炒什么好吃| 三候是什么意思| 尿发红什么原因| louisvuitton什么牌子| 身骑白马是什么方言| 发什么大成语| 肋骨中间是什么器官| 感冒咳嗽吃什么药止咳效果好| 派对是什么意思| 居住证签注是什么意思| 补票是什么意思| 护理学和护理有什么区别| 通告是什么意思| 角弓反张是什么意思| 子宫囊肿有什么症状| 布谷鸟长什么样| 单发房早是什么意思| tct是检查什么的| 梦到龙预示着什么| 人属于什么界门纲目科属种| loho是什么牌子| 慢性支气管炎吃什么药好| 夜未央什么意思| 吃什么会自然流产| 静脉曲张什么症状| 梦见人头是什么征兆| 国家穷为什么不多印钱| cbd是什么意思啊| 蓉字五行属什么| 啐了一口是什么意思| 低血糖会出现什么症状| UDCA是什么药| 用盐水洗脸有什么好处| 鹤立鸡群代表什么生肖| 什么不可当| 一个夸一个瓜念什么| 颌下淋巴结肿大挂什么科| 78年属什么| 为什么上课会犯困| 百度Jump to content

专家建言蜀道文化传播:以三国为魂造“国际IP”

From Wikipedia, the free encyclopedia
百度 接着,区委常委李泽玉作了热情洋溢的致辞。

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-05.
  2. ^ The Open Group. "The Open Group Base Specifications Issue 7, IEEE Std 1003.1-2008, 2016 Edition". <stdio.h>. Retrieved 2025-08-05.
  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-05.
  6. ^ Stephen Kitt, Michael Kerrisk. "close_range(2) — Linux manual page". Retrieved 2025-08-05.
  7. ^ Extended API Set, Part 2. The Open Group. October 2006. ISBN 1931624674.
  8. ^ Brinkmann, Marcus (2025-08-05). "Building a bridge: library API's and file descriptors?". cap-talk. Archived from the original on 2025-08-05. Retrieved 2025-08-05.
  9. ^ de Boyne Pollard, Jonathan (2007). "Don't set shared file descriptors to non-blocking I/O mode". Retrieved 2025-08-05.
六月九号什么星座 十一月底是什么星座 重阳节是什么意思 氯化钾是什么东西 为什么智齿到晚上更疼
富裕是什么意思 t波改变是什么意思 嘉靖为什么不杀海瑞 那敢情好是什么意思 发热是什么原因
胰腺炎挂什么科 cl是什么牌子 凉瓜是什么瓜 心肾两虚吃什么中成药 堃是什么意思
张的五行属性是什么 橡胶过敏是什么症状 衣带渐宽终不悔是什么意思 活在当下什么意思 经常放屁是什么问题
什么水越洗越脏hcv9jop4ns5r.cn 牛肉不能跟什么一起吃hcv8jop5ns5r.cn 梦到蜘蛛是什么意思hanqikai.com 做梦吃肉是什么征兆hcv7jop7ns0r.cn 孝敬是什么意思hcv9jop5ns1r.cn
vt是什么hcv7jop9ns0r.cn 什么叫大数据ff14chat.com 重庆五行属什么hcv9jop6ns5r.cn 直肠息肉有什么症状hcv9jop1ns3r.cn 护士最高职称是什么wuhaiwuya.com
业障是什么意思hcv9jop5ns6r.cn 70a是什么尺码xjhesheng.com 舌头紫色是什么原因hcv7jop6ns8r.cn 6月底是什么星座hcv8jop8ns3r.cn 2.5什么星座hcv7jop6ns3r.cn
射手座是什么象星座hcv8jop2ns5r.cn 多头是什么意思hcv8jop1ns1r.cn 性疾病都有什么症状hcv8jop3ns4r.cn 晚上尿多什么原因hcv9jop8ns3r.cn reed是什么意思hcv8jop4ns6r.cn
百度