unix进程ID的基数是10吗?

发布于 2024-09-27 12:40:38 字数 169 浏览 6 评论 0原文

在阅读了一系列手册页并通过谷歌搜索后,我决定将这个问题发布给堆栈溢出的聪明人。

我正在开发一个基本的 Unix Shell,其中一个要求是我必须实现一个命令来以 10 进制 ASCII 形式回显 shell 的 pid...在我阅读此要求之前,我假设进程 id 已经是基本的10 个数字。有谁知道这是真的吗?

After reading a series of man pages and searching through google, I decided to post this question to the bright folks of stack overflow.

I'm working on a basic Unix Shell and one of the requirements is that I have to implement a command to echo out the shell's pid in base 10 ASCII... Before I read this requirement, I had assumed that process id's were already base 10 numbers. Does anyone know if this is true?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

ゃ人海孤独症 2024-10-04 12:40:38

从技术上讲,getpid() 返回的数字以 2 为基数。 :-)

认真地说,该要求可能只是意味着数字应该显示为十进制数字,而不是十六进制数字。不过,我会要求澄清这一要求,因为你不得不问。

Technically speaking, the numbers that are returned by getpid() are in base two. :-)

Seriously speaking, the requirement probably just means that the number should be displayed as a decimal number as opposed to, for example, a hexadecimal number. I would ask for clarification of that requirement though, since you had to ask.

熟人话多 2024-10-04 12:40:38

数字本身没有底数。它们只是代表一种价值。如果你有十七个 goats 独角兽,那么无论你选择以什么基数写下来,你仍然拥有相同数量的独角兽。

一旦你决定使用人类可读的表示形式打印一个值,那么你必须选择一个基地。您的要求是用户希望看到以 10 为基数表示的 PID。

Numbers themselves don't have a base. They just represent a value. If you have seventeen goats unicorns, then you still have the same number of unicorns no matter what base you choose to write that down in.

Once you decide to print a value using a human readable representation, then you have to choose a base. Your requirement is that the user expects to see the PID in a base 10 representation.

绝對不後悔。 2024-10-04 12:40:38

当然,它们是[由系统实用程序以 10 为基数打印的]。

Of course, they are [printed in base 10 by system utilities].

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文