问题
Shouldn't the standard input for different process unique? If so, shouldn't the path of the stdin file be like /dev/pid/stdin
instead of a global /dev/stdin
?
Does anyone have ideas about this?
回答1:
/dev/stdin
is unique because
- it is a symbolic link to
/proc/self/fd/0
/proc/self
is a symbolic link only seen by your running process to its process-id
The /proc
filesystem is a virtual (not real) filesystem which has the ability to show a different view to each process.
Further reading:
- Linux Filesystem Hierarchy: 1.14. /proc
- Red Hat Enterprise Linux 3: Reference Guide: Chapter 5. The proc File System
来源:https://stackoverflow.com/questions/36615360/in-linux-why-is-there-a-global-dev-stdin-file-for-all-processes