在 C 中使用 open() 函数时,我得到一个 fd(文件描述符)。我想知道它是否与其进程 ID 相同,因为据我所知,fd 是一个整数。
最佳答案
不,不是。
PID是进程标识符,文件描述符是文件处理程序标识符。
特别来自维基百科关于文件描述符的内容:
(...) file descriptor (FD) is an abstract indicator for accessing a file. The term is generally used in POSIX operating systems.
In POSIX, a file descriptor is an integer, specifically of the C type int. (...)
对于 PID:
[PID] is a number used by most operating system kernels, — such as that of UNIX, Mac OS X or Microsoft Windows — to temporarily uniquely identify a process (...)
关于c - 文件描述符(在 C 中打开的 fd)是否与其进程 ID 相同?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26653265/