【问题标题】:What does the FD column of pipes listed by lsof mean?lsof列出的管道的FD列是什么意思?
【发布时间】:2014-09-28 05:28:51
【问题描述】:

我正在使用以下命令来获取管道列表:

lsof | grep PIPE 

我想知道 FD 列的值是什么意思(第 5 个 http://i.imgur.com/KHczptf.png)。我认为 rw 分别表示 readwrite,但是每个字符后面的数字是什么意思?


我知道FD表示文件描述符,我想弄清楚列中显示的值是什么意思,比如3r、16w、20r等。

【问题讨论】:

  • 现在正在阅读,我发现 w 和 r 真正的意思是写和读。但我还是不知道这个数字是什么意思。

标签: linux shell command file-descriptor lsof


【解决方案1】:

文件不仅作为流打开。其中一些列在lsof 的手册中:

FD    is the File Descriptor number of the file or:

           cwd  current working directory;
           Lnn  library references (AIX);
           err  FD information error (see NAME column);
           jld  jail directory (FreeBSD);
           ltx  shared library text (code and data);
           Mxx  hex memory-mapped type number xx.
           m86  DOS Merge mapped file;
           mem  memory-mapped file;
           mmap memory-mapped device;
           pd   parent directory;
           rtd  root directory;
           tr   kernel trace file (OpenBSD);
           txt  program text (code and data);
           v86  VP/ix mapped file;

      FD  is  followed  by one of these characters, describing the
      mode under which the file is open:

           r for read access;
           w for write access;
           u for read and write access;
           space if mode unknown and no lock
            character follows;
           '-' if mode unknown and lock
            character follows.

      The mode character is followed by one of these lock  charac-
      ters, describing the type of lock applied to the file:

           N for a Solaris NFS lock of unknown type;
           r for read lock on part of the file;
           R for a read lock on the entire file;
           w for a write lock on part of the file;
           W for a write lock on the entire file;
           u for a read and write lock of any length;
           U for a lock of unknown type;
           x  for an SCO OpenServer Xenix lock on part  of the
      file;
           X for an SCO OpenServer Xenix lock on  the   entire
      file;
           space if there is no lock.

      See  the  LOCKS  section  for  more  information on the lock
      information character.

      The FD column contents constitutes a single field for  pars-
      ing in post-processing scripts.

【讨论】:

  • 没用的答案/
【解决方案2】:

文件描述符

更多:

文件描述符 (FD) 是用于访问文件的抽象指示符。该术语通常用于 POSIX 操作系统。

在 POSIX 中,文件描述符是一个整数,特别是 C 类型的 int。有三个标准 POSIX 文件描述符,对应于三个标准流,大概每个进程(可能保存一个守护进程)都应该拥有。

【讨论】:

  • 对不起伊戈尔,也许我没有正确表达自己。我知道 FD 表示文件描述符,但我想确切地知道数字和字符的含义。在 wiki 中显示 0、1 和 2 是 stdin、stdout 和 stderr,但是 16r 呢?
  • r 表示读取权限,即文件以只读模式打开,16 只是描述符的数字。它没有特别的意义。您可以在/proc/PID/fd/FD 访问该文件,其中 PID 和 FD 是进程的 pid 和描述符的编号。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-10-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多