Unix和Linux /proc PID系统

时间:2022-12-04 19:24:03

For my intro to operating systems class we were introduced to the /proc directory and many of the features that can be used to access data stored in the process ID's that are available in /proc.

在我的操作系统类介绍中,我们介绍了/proc目录和许多特性,这些特性可以用于访问存储在进程ID中的、在/proc中可用的数据。

When I was trying out some of the commands learned (and a few I looked up) on the UNIX server hosted by my school I noticed that some of the sub directories that were present in a process, that I created, were a file type called "TeX font metric data" or a .tfm file. I figured that was the file type that was used when my professor showed us how to get data from the directories like status and map.

当我尝试一些命令的学习(和一些我抬头)主持的UNIX服务器上我的学校我注意到的子目录中一个过程,我创建的,是一个文件类型称为“特克斯字体度量数据”或一个.tfm文件。我认为这是我的教授向我们展示如何从状态和映射等目录中获取数据时使用的文件类型。

When I entered the command cat /proc/(PID)/status to look into the status file I got a random assortment of characters and white space. When I tried the same command on a process I created in my schools Linux server I was shown the information I expected to see in the status and map files.

当我输入命令cat /proc/(PID)/status以查看状态文件时,我得到了随机的字符和空格。当我在我的学校Linux服务器上创建的进程上尝试相同的命令时,我看到的信息显示在状态和映射文件中。

My question is:

我的问题是:

why did the Unix server produce the random characters from my process's /proc/(PID)/status file while the Linux server gave me the data I would expect from the same command? Also Is there a way to access the Unix /proc data by accessing the /proc directory?

为什么Unix服务器从我的进程的/proc/(PID)/status文件中生成随机字符,而Linux服务器向我提供我希望从相同命令中得到的数据?还有通过访问/proc目录访问Unix /proc数据的方法吗?

1 个解决方案

#1


2  

The Linux procfs you are familiar with, aka /proc/ is not a POSIX thing. It's OS-specific and multiple OSes just happen to implement similar things also called /proc.

您熟悉的Linux procfs,也就是/proc/不是POSIX的东西。它是特定于操作系统的,多个操作系统恰好实现了类似的东西,也称为/proc。

Because no formal standard covers it, it's allowed to be / going to be different on any *nix-like system that implements it.

因为没有正式的标准覆盖它,所以在任何实现它的类*nix系统上,它都可以是不同的。

My guess with /proc/(PID)/status is that your UNIX is dumping the process status in a binary form instead of easy to read plain text.

我对/proc/(PID)/状态的猜测是,您的UNIX将进程状态以二进制形式转储,而不是简单地读取纯文本。

See also: Knowing the process status using procf/<pid>/status

参见:使用procf/ /status了解进程状态

If you can determine WHAT Unix you're on (odds are, Solaris since there's a free variant) you should be able to find a more specific answer.

如果您能够确定您使用的Unix(很有可能是Solaris,因为有一个免费的变体),那么您应该能够找到一个更具体的答案。

#1


2  

The Linux procfs you are familiar with, aka /proc/ is not a POSIX thing. It's OS-specific and multiple OSes just happen to implement similar things also called /proc.

您熟悉的Linux procfs,也就是/proc/不是POSIX的东西。它是特定于操作系统的,多个操作系统恰好实现了类似的东西,也称为/proc。

Because no formal standard covers it, it's allowed to be / going to be different on any *nix-like system that implements it.

因为没有正式的标准覆盖它,所以在任何实现它的类*nix系统上,它都可以是不同的。

My guess with /proc/(PID)/status is that your UNIX is dumping the process status in a binary form instead of easy to read plain text.

我对/proc/(PID)/状态的猜测是,您的UNIX将进程状态以二进制形式转储,而不是简单地读取纯文本。

See also: Knowing the process status using procf/<pid>/status

参见:使用procf/ /status了解进程状态

If you can determine WHAT Unix you're on (odds are, Solaris since there's a free variant) you should be able to find a more specific answer.

如果您能够确定您使用的Unix(很有可能是Solaris,因为有一个免费的变体),那么您应该能够找到一个更具体的答案。