有什么方法可以防止mc
花10到30秒的时间打开?
strace -r -tt -o mc.strace mc
看看它在哪里花时间。如果需要帮助解释它,请上载跟踪文件。请注意,跟踪文件可能包含私有信息(至少是文件名),请在上载前对其进行查看和清理(如有必要)。
有什么方法可以防止mc
花10到30秒的时间打开?
strace -r -tt -o mc.strace mc
看看它在哪里花时间。如果需要帮助解释它,请上载跟踪文件。请注意,跟踪文件可能包含私有信息(至少是文件名),请在上载前对其进行查看和清理(如有必要)。
Answers:
现在对我有用。我在用
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
干杯!
mc / subshell集成是常见的罪魁祸首;进行验证,请尝试:
alias mc="mc --nosubshell"
校验
host `hostname`
快速取得结果
MC首先使用主机名连接到内部服务
在Fedora 18上的类似情况下,我将主机名值添加到/ etc / hosts中,这很有帮助。
alias mc='TERM=linux mc'
host 'hostname'
?它返回与相同的结果host 'aaaa'
,host 'aaab'
以及不存在的主机的无穷列表。是不是意味着MC正在尝试解决不存在的主机?
由于启动子外壳程序(按Ctrl-O时显示)并仅在子外壳程序启动时才显示UI,因此启动可能很慢。我使用zsh,并且在删除~/.zshrc
文件时注意到mc立即启动。
开始大约花了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
...
查看此输出,我决定从mc
empty PROMPT_COMMAND
(PROMPT_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
,它会阻止进程直到超时。如果我错了纠正我。
PROMPT_COMMAND
。我遇到了同样的问题,我也通过history -a
从我的问题中删除来解决了这个问题,PROMPT_COMMAND
但是我不知道为什么这样做有帮助,我也不知道这和之间的联系在哪里select(8, [6,7], ...)
(这显然导致MC随着超时而变慢)。也许您可以帮助我了解解决方案。
;
在PROMPT_COMMAND
确实有超时的效果相同。我知道将其添加history -a
回我的PROMPT_COMMAND
(内~/.local/share/mc/bashrc
),一切正常。尽管仍很有趣;
我这个问题已经很长时间了,最终我不再使用Midnight Commander ...
但是我最近找到了解决方案!!!就我而言,它仅与我的其他外壳有关:我正在使用鱼。http://fishshell.com/
两者结合起来效果不佳。我只是更改了脚本,以确保mc使用bash而不是fish。
刚刚在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双向快速启动。
--enable-vfs-smb
吗?尝试禁用该功能。似乎是版本4.8.4的常见问题:mc启动速度非常慢