在Linux中,为什么所有进程都存在全局/dev/stdin文件? [英] In Linux, why is there a global /dev/stdin file for all processes?

查看:290
本文介绍了在Linux中,为什么所有进程都存在全局/dev/stdin文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

不同工艺的标准输入不是唯一的吗?如果是这样,stdin文件的路径不应该像/dev/pid/stdin那样而不是全局的/dev/stdin吗?

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?

有人对此有想法吗?

推荐答案

/dev/stdin是唯一的,因为

  • 这是指向/proc/self/fd/0
  • 的符号链接
  • /proc/self是正在运行的进程看到的 进程ID
  • 的符号链接,仅
  • 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

/proc文件系统是一个 虚拟 (不是 real )文件系统,可以显示每个过程都有不同的看法.

The /proc filesystem is a virtual (not real) filesystem which has the ability to show a different view to each process.

进一步阅读:

  • Linux Filesystem Hierarchy: 1.14. /proc
  • Red Hat Enterprise Linux 3: Reference Guide: Chapter 5. The proc File System

这篇关于在Linux中,为什么所有进程都存在全局/dev/stdin文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆