午夜指挥官的启动缓慢


19

有什么方法可以防止mc花10到30秒的时间打开?


1
你用它编译了--enable-vfs-smb吗?尝试禁用该功能。似乎是版本4.8.4的常见问题:mc启动速度非常慢
Marco

2
奔跑strace -r -tt -o mc.strace mc看看它在哪里花时间。如果需要帮助解释它,请上载跟踪文件。请注意,跟踪文件可能包含私有信息(至少是文件名),请在上载前对其进行查看和清理(如有必要)。
吉尔斯(Gilles)“所以,别再邪恶了”

1
有同样的问题,将主机名添加到/ etc / hosts(当然是127.0.0.1),一切都变得完美了

Answers:


5

现在对我有用。我在用

GNU午夜指挥官4.8.21

strace等待很长时间

connect(3, {sa_family=AF_INET, sin_port=htons(6011),
  sin_addr=inet_addr("x.x.x.x")}, 16) = ? ERESTARTSYS
  (To be restarted if SA_RESTART is set)' 

我尝试了这个:

# hostname

将此用于/etc/hosts

nameofhost=hostname

将此添加$nameofhost/etc/hosts在线开始

127.0.0.1 localhost ... $nameofhost 

干杯!



10

实际上,编辑/ etc / hosts为我解决了这个问题。
由于启动期间mc尝试将本地主机名解析为IP地址,因此我的mc花了10秒钟启动。
我在/ etc / hosts中添加了以下行(我的主机名是FOO), 127.0.0.2 FOO.domain FOO 这立即解决了问题。


您为什么使用127.0.0.2但不使用127.0.0.1
昏暗的

127.xyz中的任何x,y,z都可以很好地工作(整个IP范围保留给本地计算机)
ggpp23

5

校验

host `hostname`

快速取得结果

MC首先使用主机名连接到内部服务

在Fedora 18上的类似情况下,我将主机名值添加到/ etc / hosts中,这很有帮助。


mc内部服务?可能是我们可以更改某些配置来修复mc,而不需要更改/ etc / hosts吗?还是/ etc / hosts损坏了,mc希望它可以得到纠正?
Aquarius Power

哦,我才发现它在这里有效:alias mc='TERM=linux mc'
Aquarius Power

从某些角度来看,/ etc / hosts实际上是损坏的。无法将自己的主机名解析为自己的ip。我不知道为什么mc在那里依赖它。
mmv-ru 2015年

1
你是什么意思host 'hostname'?它返回与相同的结果host 'aaaa'host 'aaab'以及不存在的主机的无穷列表。是不是意味着MC正在尝试解决不存在的主机?
Dims

抱歉,单引号必须位于撇号位置。答案固定。以某种方式是。MC通过您的主机名连接到自己的服务器,因此它会获得不存在的主机并进行多次尝试。
mmv-ru

4

由于启动子外壳程序(按Ctrl-O时显示)并仅在子外壳程序启动时才显示UI,因此启动可能很慢。我使用zsh,并且在删除~/.zshrc文件时注意到mc立即启动。


2
请参阅midnight-commander.org/ticket/3580,了解如何通过在后台启动subshel​​l来进行改进。
aleb

那么,需要重新编译吗?
Panayotis

3

开始大约花了10秒钟mc。运行strace -r -tt -o mc.strace mc我得到:

...
 0.000023 pipe([7, 8])              = 0
 0.000028 clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7fcad000fa50) = 3332
 0.000247 write(5, " PROMPT_COMMAND=${PROMPT_COMMAND"..., 75) = 75
 0.000050 rt_sigaction(SIGINT, {0x449960, [], SA_RESTORER, 0x7fcaced23740}, NULL, 8) = 0
 0.000034 select(8, [5 7], NULL, NULL, {10, 0}) = 1 (in [5], left {9, 999996})
 0.000039 read(5, " PROMPT_COMMAND=${PROMPT_COMMAND"..., 128) = 76
 0.000032 select(8, [5 7], NULL, NULL, {9, 999996}) = 1 (in [5], left {9, 985005})
 0.015050 read(5, "[yuri@yuri ~]  PROM", 128) = 19
 0.000031 select(8, [5 7], NULL, NULL, {9, 985005}) = 1 (in [5], left {9, 985001})
 0.000036 read(5, "PT_COM", 128)    = 6
 0.000026 select(8, [5 7], NULL, NULL, {9, 985001}) = 1 (in [5], left {9, 984998})
 0.000033 read(5, "MAND=", 128)     = 5
 0.000026 select(8, [5 7], NULL, NULL, {9, 984998}) = 1 (in [5], left {9, 984995})
 0.000033 read(5, "${PR", 128)      = 4
 0.000025 select(8, [5 7], NULL, NULL, {9, 984995}) = 1 (in [5], left {9, 984992})
 0.000034 read(5, "OMPT", 128)      = 4
 0.000025 select(8, [5 7], NULL, NULL, {9, 984992}) = 1 (in [5], left {9, 984989})
 0.000034 read(5, "_COM", 128)      = 4
 0.000026 select(8, [5 7], NULL, NULL, {9, 984989}) = 1 (in [5], left {9, 984986})
 0.000034 read(5, "MAND", 128)      = 4
 0.000025 select(8, [5 7], NULL, NULL, {9, 984986}) = 1 (in [5], left {9, 984983})
 0.000033 read(5, ":+$", 128)       = 3
 0.000025 select(8, [5 7], NULL, NULL, {9, 984983}) = 1 (in [5], left {9, 984980})
 0.000033 read(5, "PRO", 128)       = 3
 0.000025 select(8, [5 7], NULL, NULL, {9, 984980}) = 1 (in [5], left {9, 984977})
 0.000033 read(5, "MPT", 128)       = 3
 0.000025 select(8, [5 7], NULL, NULL, {9, 984977}) = 1 (in [5], left {9, 984974})
 0.000033 read(5, "_CO", 128)       = 3
 0.000025 select(8, [5 7], NULL, NULL, {9, 984974}) = 1 (in [5], left {9, 984971})
 0.000033 read(5, "MMA", 128)       = 3
 0.000026 select(8, [5 7], NULL, NULL, {9, 984971}) = 1 (in [5], left {9, 984968})
 0.000032 read(5, "ND;", 128)       = 3
 0.000025 select(8, [5 7], NULL, NULL, {9, 984968}) = 1 (in [5], left {9, 984965})
 0.000033 read(5, " }", 128)        = 2
 0.000026 select(8, [5 7], NULL, NULL, {9, 984965}) = 1 (in [5], left {9, 984962})
 0.000033 read(5, "'pw", 128)       = 3
 0.000025 select(8, [5 7], NULL, NULL, {9, 984962}) = 1 (in [5], left {9, 984959})
 0.000033 read(5, "d>", 128)        = 2
 0.000026 select(8, [5 7], NULL, NULL, {9, 984959}) = 1 (in [5], left {9, 984956})
 0.000032 read(5, "&8;", 128)       = 3
 0.000026 select(8, [5 7], NULL, NULL, {9, 984956}) = 1 (in [5], left {9, 984953})
 0.000032 read(5, "ki", 128)        = 2
 0.000025 select(8, [5 7], NULL, NULL, {9, 984953}) = 1 (in [5], left {9, 984950})
 0.000033 read(5, "ll ", 128)       = 3
 0.000026 select(8, [5 7], NULL, NULL, {9, 984950}) = 1 (in [5], left {9, 984947})
 0.000032 read(5, "-S", 128)        = 2
 0.000025 select(8, [5 7], NULL, NULL, {9, 984947}) = 1 (in [5], left {9, 984944})
 0.000033 read(5, "TO", 128)        = 2
 0.000025 select(8, [5 7], NULL, NULL, {9, 984944}) = 1 (in [5], left {9, 984941})
 0.000033 read(5, "P ", 128)        = 2
 0.000025 select(8, [5 7], NULL, NULL, {9, 984941}) = 1 (in [5], left {9, 984938})
 0.000033 read(5, "$$", 128)        = 2
 0.000033 select(8, [5 7], NULL, NULL, {9, 984938}) = 1 (in [5], left {9, 984935})
 0.000034 read(5, "'\r\n", 128)     = 3
 0.000025 select(8, [5 7], NULL, NULL, {9, 984935}) = 1 (in [5], left {9, 984886})
 0.000082 read(5, "bash: PROMPT_COMMAND: line 1: sy"..., 128) = 128
 0.000033 select(8, [5 7], NULL, NULL, {9, 984886}) = 1 (in [5], left {9, 984882})
 0.000071 read(5, "tory -r; ; pwd>&8;kill -STOP $$'"..., 128) = 48
 0.000061 select(8, [5 7], NULL, NULL, {9, 984882}) = 0 (Timeout)
 9.995037 rt_sigaction(SIGINT, {SIG_IGN, [], SA_RESTORER, 0x7fcaced23740}, NULL, 8) = 0
 0.000090 write(1, "\33[?1001s\33[?1002h\33[?1006h", 24) = 24
 0.000066 write(1, "\33[?2004h", 8) = 8
 0.000034 geteuid()                 = 1000
 0.000064 access("/home/yuri/.config/mc/filehighlight.ini", R_OK) = -1 ENOENT (No such file or directory)
 0.000061 access("/etc/mc/filehighlight.ini", R_OK) = 0
 0.000042 access("/etc/mc/filehighlight.ini", R_OK) = 0
 0.000044 stat("/etc/mc/filehighlight.ini", {st_mode=S_IFREG|0644, st_size=1119, ...}) = 0
 0.000035 open("/etc/mc/filehighlight.ini", O_RDONLY) = 9
...

查看此输出,我决定从mcempty PROMPT_COMMANDPROMPT_COMMAND= mc)开始,然后立即开始。我曾经有过共同之处:

history -a; history -c; history -r;

UPD经过进一步的挖掘,事实证明它与历史(PROMPT_COMMAND=';' strace -r -tt -o mc.strace -s 1000 mc)没有关系:

 0.000197 write(5, " PROMPT_COMMAND=${PROMPT_COMMAND:+$PROMPT_COMMAND; }'pwd>&8;kill -STOP $$'\n", 75) = 75
 0.000068 rt_sigaction(SIGINT, {0x449960, [], SA_RESTORER, 0x7f12567fc660}, NULL, 8) = 0
 0.000049 select(8, [5 7], NULL, NULL, {10, 0}) = 1 (in [5], left {9, 999996})
 0.000055 read(5, " PROMPT_COMMAND=${PROMPT_COMMAND:+$PROMPT_COMMAND; }'pwd>&8;kill -STOP $$'\r\n", 128) = 76
 0.000050 select(8, [5 7], NULL, NULL, {9, 999996}) = 1 (in [5], left {9, 981008})
 0.019073 read(5, "bash: PROMPT_COMMAND: line 0: syntax error near unexpected token `;'\r\nbash: PROMPT_COMMAND: line 0: `;'\r\n", 128) = 105
 0.000041 select(8, [5 7], NULL, NULL, {9, 981008}) = 1 (in [5], left {9, 980786})
 0.000292 read(5, "[\33[1;30myuri\33[0m@\33[1;33myuri\33[0m ~]  PROM", 128) = 41
 0.000070 select(8, [5 7], NULL, NULL, {9, 980786}) = 1 (in [5], left {9, 980782})
 0.000075 read(5, "PT_COMMAN", 128) = 9
 0.000061 select(8, [5 7], NULL, NULL, {9, 980782}) = 1 (in [5], left {9, 980778})
 0.000058 read(5, "D=${PRO", 128)   = 7
 0.000047 select(8, [5 7], NULL, NULL, {9, 980778}) = 1 (in [5], left {9, 980775})
 0.000059 read(5, "MPT_CO", 128)    = 6
 0.000048 select(8, [5 7], NULL, NULL, {9, 980775}) = 1 (in [5], left {9, 980772})
 0.000058 read(5, "MMAND", 128)     = 5
 0.000047 select(8, [5 7], NULL, NULL, {9, 980772}) = 1 (in [5], left {9, 980768})
 0.000056 read(5, ":+$P", 128)      = 4
 0.000047 select(8, [5 7], NULL, NULL, {9, 980768}) = 1 (in [5], left {9, 980764})
 0.000057 read(5, "ROMPT", 128)     = 5
 0.000047 select(8, [5 7], NULL, NULL, {9, 980764}) = 1 (in [5], left {9, 980761})
 0.000056 read(5, "_COM", 128)      = 4
 0.000047 select(8, [5 7], NULL, NULL, {9, 980761}) = 1 (in [5], left {9, 980758})
 0.000057 read(5, "MAND", 128)      = 4
 0.000046 select(8, [5 7], NULL, NULL, {9, 980758}) = 1 (in [5], left {9, 980755})
 0.000057 read(5, "; }'", 128)      = 4
 0.000046 select(8, [5 7], NULL, NULL, {9, 980755}) = 1 (in [5], left {9, 980752})
 0.000056 read(5, "pwd>", 128)      = 4
 0.000047 select(8, [5 7], NULL, NULL, {9, 980752}) = 1 (in [5], left {9, 980749})
 0.000057 read(5, "&8;k", 128)      = 4
 0.000047 select(8, [5 7], NULL, NULL, {9, 980749}) = 1 (in [5], left {9, 980746})
 0.000057 read(5, "ill", 128)       = 3
 0.000058 select(8, [5 7], NULL, NULL, {9, 980746}) = 1 (in [5], left {9, 980743})
 0.000057 read(5, " -ST", 128)      = 4
 0.000046 select(8, [5 7], NULL, NULL, {9, 980743}) = 1 (in [5], left {9, 980740})
 0.000058 read(5, "OP ", 128)       = 3
 0.000046 select(8, [5 7], NULL, NULL, {9, 980740}) = 1 (in [5], left {9, 980736})
 0.000056 read(5, "$$'\r\n", 128)   = 5
 0.000048 select(8, [5 7], NULL, NULL, {9, 980736}) = 1 (in [5], left {9, 980721})
 0.000069 read(5, "bash: PROMPT_COMMAND: line 1: syntax error near unexpected token `;;'\r\nbash: PROMPT_COMMAND: line 1: `;; pwd>&8;kill -STOP $$'\r\n", 128) = 128
 0.000049 select(8, [5 7], NULL, NULL, {9, 980721}) = 1 (in [5], left {9, 980713})
 0.000062 read(5, "[\33[1;30myuri\33[0m@\33[1;33myuri\33[0m ~] ", 128) = 36
 0.000047 select(8, [5 7], NULL, NULL, {9, 980713}) = 0 (Timeout)
 9.990855 rt_sigaction(SIGINT, {SIG_IGN, [], SA_RESTORER, 0x7f12567fc660}, NULL, 8) = 0

我的关头是mc与混乱PROMPT_COMMAND以错误的方式。它会更改PROMPT_COMMAND,如果包含;,则会触发bash错误。因此,不会将任何内容写入描述符8,它会阻止进程直到超时。如果我错了纠正我。


1
我知道这是一个古老的答案。但是也许我很幸运,你介意解释为什么从strace输出中得出结论:出问题了PROMPT_COMMAND。我遇到了同样的问题,我也通过history -a从我的问题中删除来解决了这个问题,PROMPT_COMMAND但是我不知道为什么这样做有帮助,我也不知道这和之间的联系在哪里select(8, [6,7], ...)(这显然导致MC随着超时而变慢)。也许您可以帮助我了解解决方案。
degill 2015年

@degill请参阅我的最新答案。
x-yuri 2015年

感谢更新!你是对的,只是把;PROMPT_COMMAND确实有超时的效果相同。我知道将其添加history -a回我的PROMPT_COMMAND(内~/.local/share/mc/bashrc),一切正常。尽管仍很有趣;
degill

4
上游错误条目位于midnight-commander.org/ticket/3534
egmont

2

我这个问题已经很长时间了,最​​终我不再使用Midnight Commander ...

但是我最近找到了解决方案!!!就我而言,它仅与我的其他外壳有关:我正在使用鱼。http://fishshell.com/

两者结合起来效果不佳。我只是更改了脚本,以确保mc使用bash而不是fish。


为什么鱼会引起这样的问题?

2

刚刚在FreeBSD上解决了同样的问题。我认为,/etc/hosts通过以下方式进行编辑更正确:

127.0.0.1 localhost localhost.my.domain myhost.my.domain myhost

因为hosts文件输入语法为(请参阅hosts(5)-Linux手册页):

IP_address canonical_hostname [aliases...]

因此,如果您仅在hosts文件中添加类似

127.0.0.2 myhost.my.domain myhost

那么你会得到

root@myhost:~# ping myhost
PING myhost.my.domain (127.0.0.2): 56 data bytes
ping: sendto: Can't assign requested address
ping: sendto: Can't assign requested address
ping: sendto: Can't assign requested address
ping: sendto: Can't assign requested address
^C
--- myhost.my.domain ping statistics ---
4 packets transmitted, 0 packets received, 100.0% packet loss

但是,如果hosts像第一个示例一样编辑文件,您将获得正确的ping答案:

root@myhost:~# ping myhost
PING localhost (127.0.0.1): 56 data bytes
64 bytes from 127.0.0.1: icmp_seq=0 ttl=64 time=0.060 ms
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.050 ms
64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.030 ms
64 bytes from 127.0.0.1: icmp_seq=3 ttl=64 time=0.040 ms
64 bytes from 127.0.0.1: icmp_seq=4 ttl=64 time=0.046 ms
64 bytes from 127.0.0.1: icmp_seq=5 ttl=64 time=0.036 ms
^C
--- localhost ping statistics ---
6 packets transmitted, 6 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 0.030/0.044/0.060/0.010 ms

MC双向快速启动。


2
mc -X

为我工作(禁用xterm)


这也是我的问题。DISPLAY环境变量设置为localhost:10.0,但是没有X服务器在该服务器上监听且没有显示。
fviktor '19

0

如果使用MobaXterm连接到服务器上的SSH,则可能需要关闭X11转发才能很快启动mc。这就是使mc启动变慢的原因。


-1

尝试从中删除行“搜索everything.something” /etc/resolv.conf

/etc/hosts 应该有以下几行:

127.0.0.1 localhost

127.0.0.2 hostname.domain hostname

“主机名”是您的主机名,“域”是您的域。


当计算机从未连接到网络时,这才有意义。该文件由DHCP填充(或在配置Internet连接时)。
vonbrand
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.