unix ps 命令中 TTY 是什么意思?
当我运行 PS 时,其中一列输出是 TTY。这意味着什么?特别是,“??”的值如何?与“ttys000”比较?
我之所以这么问,是因为我有一个 Java 程序通过 ProcessBuilder 执行 sort
,当该程序通过我的 IDE (IntelliJ) 运行时,该进程所需的时间比在 IDE 外部作为可执行 jar 运行时少 5 倍。
在每种情况下,我都会在排序运行时运行 ps,唯一的区别是 IDE 创建一个 TTY 为 ?? 的进程。而 jar 创建一个 TTY 为 ttys000 的进程。
When I run PS one of the columns output is TTY. What does this mean? In particular, how does as value of "??" compare with "ttys000"?
I ask because I have a Java program execute sort
via ProcessBuilder, and when this program is run via my IDE (IntelliJ) the process takes 5x less than when run as an executable jar outside the IDE.
In each case I run ps when the sort is running and the only difference is the IDE creats a process with a TTY of ?? whereas the jar creates a process with TTY of ttys000.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
TTY 是计算机终端。在 ps 上下文中,它是执行特定命令的终端。
该缩写代表“TeleTYpewriter”,是允许用户连接到早期计算机的设备。
根据您的情况,jar 创建一个名为“ttys000”的虚拟终端,但 IDE 不会连接到虚拟终端来执行命令。
A TTY is a computer terminal. In the context of
ps
, it is the terminal that executed a particular command.The abbreviation stands for "TeleTYpewriter", which were devices that allowed users to connect to early computers.
In relation to your situation, the jar creates a virtual terminal named 'ttys000' but the IDE does not attach to a virtual terminal to execute the command.
进程可以(并且通常)绑定到“控制终端”。该终端可能是串行线路末端的硬件,或者今天更可能是等效的虚拟软件。 TTY 是从父进程继承的。您的 IDE 很可能会与其 TTY 解除关联,并且当在 java 程序外部启动时,它会继承 shell 的 TTY。
A process can be (and usually is) bound to a "controlling terminal". This terminal may be hardware at the end of a serial line, or much more likely today, be a virtual software equivalent. The TTY is inherited from the parent process. Most likely your IDE disassociates itself from its TTY, and when started outside your java program inherits your shell's TTY.