Search code examples
linuxsocketsunixlinux-kernelfile-descriptor

How does a system call know what process a file descriptor belong to?


I've heard that file descriptors are unique to each process. But, are they unique to the entire system? How are they handled within the kernel? If file descriptors are not unique system-wide, how does a system call, like read, write, close, etc, know what process the file descriptor they receive belong to?


Solution

  • Invoking a system call does not involve a change of PID; the system call simply looks at the FD table of the current PID.