Ctrl-t在终端进行“git push”操作时显示什么信息?

6
我在Mac OS X终端上运行git。 在长时间运行“git push”时,我意外按下了ctrl-t,然后显示出一些“load”信息。 我想这是有关正在运行的进程的某些信息,但我找不到相关文档。
这些信息表示什么?
示例运行:
danbj$ git push
Counting objects: 5, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (5/5), 503 bytes | 0 bytes/s, done.
Total 5 (delta 2), reused 0 (delta 0)
remote: Resolving deltas: 100% (2/2), completed with 2 local objects.
**load: 1.94  cmd: ssh 30002 waiting 0.01u 0.01s**
load: 2.11  cmd: ssh 30002 waiting 0.01u 0.01s
load: 2.11  cmd: ssh 30002 waiting 0.01u 0.01s
load: 2.10  cmd: ssh 30002 waiting 0.01u 0.01s
load: 2.10  cmd: ssh 30002 waiting 0.01u 0.01s
load: 2.09  cmd: ssh 30002 waiting 0.01u 0.01s
load: 2.09  cmd: ssh 30002 waiting 0.01u 0.01s
load: 2.08  cmd: ssh 30002 waiting 0.01u 0.01s
2个回答

14

在MacOS上,Control-T来自BSD。它是来自stty设置的status字符:

$ stty -a
[snip]
cchars: discard = ^O; dsusp = ^Y; eof = ^D; eol = <undef>;
    eol2 = <undef>; erase = ^H; intr = ^C; kill = ^X; lnext = ^V;
    min = 1; quit = ^\; reprint = ^R; start = ^Q; status = ^T;
    stop = ^S; susp = ^Z; time = 0; werase = ^W;

并且在termios(4)中有记录:

 STATUS  Special character on input and is recognized if the ICANON flag
         is set.  Receipt of this character causes a SIGINFO signal to be
         sent to the foreground process group of the terminal.  Also, if
         the NOKERNINFO flag is not set, it causes the kernel to write a
         status message to the terminal that displays the current load
         average, the name of the command in the foreground, its process
         ID, the symbolic wait channel, the number of user and system sec-
         onds used, the percentage of cpu the process is getting, and the
         resident set size of the process.

这种状态打印以及状态字符本身的存在,源于我和Rehmi Post编写的代码(还有其他几个人的参与;Fred Blonder可能也有所贡献,当然我们从斯坦福大学和麻省理工学院招来的研究生也参与其中),那是在我在马里兰大学时,大约是1980年代中期至晚期。

后来在1990年代(或者更晚一些)添加了SIGINFO信号和NOKERNINFO控制标志。(据我回忆,ITSTOPS-10TOPS-20和/或TENEX/TWENEX都有类似的功能。虽然我自己从未使用过,但灵感正是来源于此。)


感谢您添加这个功能!它非常棒,我喜欢使用它。我希望它会在某个时候被添加到Linux内核(以及任何支持的GNU和/或其他软件)中,因为当我在这些系统上时,我经常发现自己需要它。 - lindes

2
在终端运行命令时按下Control+T,将显示正在执行的进程、负载、进程的PID以及其用户和内核时间。

显然,它通过发送SIGINFO信号来工作(该信号在Linux下不存在)。 - Keith Thompson
@KeithThompson:负载平均值和进程信息是在内核中打印的。默认情况下忽略SIGINFO信号,但一些程序(如BSD make)会捕获它并打印附加信息。 - torek

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接