简体   繁体   English

Unix和Linux / proc PID系统

[英]Unix and Linux /proc PID system

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目录以及许多可用于访问存储在/proc中可用的进程ID中的数据的功能。

When I was trying out some commands learned (and a few I looked up) on the UNIX server hosted by my school I noticed that some sub directories that were present in a process, that I created, were a file type called "TeX font metric data" or a .tfm file. 当我在学校托管的UNIX服务器上尝试一些了解到的命令(以及一些我查找的命令)时,我注意到我创建的进程中存在的一些子目录是名为“ TeX字体规格”的文件类型。数据”或.tfm文件。 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. 我发现那是我的教授向我们展示如何从状态和映射等目录中获取数据时使用的文件类型。

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. 当我输入命令cat /proc/(PID)/status来查看状态文件时,我得到了随机排列的字符和空格。 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. 当我在学校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? 为什么Unix服务器从进程的/proc/(PID)/status文件中产生随机字符,而Linux服务器却给了我相同命令所期望的数据呢? Also Is there a way to access the Unix /proc data by accessing the /proc directory? 还有通过访问/proc目录访问Unix /proc数据的方法吗?

The Linux procfs you are familiar with, aka /proc/ is not a POSIX thing. 您熟悉的Linux procfs(又名/proc/ )不是POSIX。 It's OS-specific and multiple OSes just happen to implement similar things also called /proc . 它是特定于操作系统的,并且多个操作系统恰好实现了类似的事情,也称为/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)/ status的猜测是,您的UNIX以二进制形式而不是易于阅读的纯文本格式转储进程状态。

See also: Knowing the process status using procf/<pid>/status 另请参阅: 使用procf / <pid> / 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),您应该能够找到更具体的答案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM