Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Is there any way to prevent mc from taking 10-30 seconds to open? Never seen this with Debian.

share|improve this question
1  
Did you compile it with --enable-vfs-smb? Try disabling the feature. Seems to be a common problem with version 4.8.4: mc starting up very SLOW –  Marco Dec 3 '12 at 12:25
2  
Run strace -r -tt -o mc.strace mc to see where it's taking time. Upload the trace file if you need help interpreting it. Note that the trace file may contain private information (at least file names), take a look at it and sanitize it if necessary before uploading. –  Gilles Dec 3 '12 at 21:38

4 Answers 4

It took about 10 seconds to start mc. Running strace -r -tt -o mc.strace mc I got:

...
 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
...

Looking at this output, I decided to start mc with empty PROMPT_COMMAND (PROMPT_COMMAND= mc), and it started instantly. I had there supposedly common:

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

UPD Upon some more digging, it turns out it has nothing to do with history (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

My conjuncture is that mc messes with PROMPT_COMMAND in a wrong way. It changes PROMPT_COMMAND so that if it contains ;, that triggers bash error. As such, nothing is written to descriptor 8, which blocks the process until timeout. Correct me, if I'm wrong.

share|improve this answer
    
I know this is an old answer and all. But maybe I am lucky and you mind explaning why you conclude from the strace output that something was wrong with PROMPT_COMMAND. I had the same issue and I also solved it by removing history -a from my PROMPT_COMMAND but I have no idea why that helps and I have no idea where the connection between that and select(8, [6,7], ...) (which apparently causes the slow down of MC with the timeout) is. Maybe you can help me understand the solution. –  degill Aug 29 at 18:50
    
@degill Please see my updated answer. –  x-yuri Aug 29 at 22:39
    
Thanks for the update! You are right, just putting ; in the PROMPT_COMMAND does have the same effect of timing out. I know added history -a back to my PROMPT_COMMAND (within ~/.local/share/mc/bashrc) and everything works fine. Still interesting though what is up with the ; –  degill Aug 30 at 9:51

Actually editing /etc/hosts solved the problem for me.
My mc took 10 seconds to start due to the fact that during startup mc tries to resolve the local hostname to an IP address.
I added to /etc/hosts the following line (my hostname is FOO) 127.0.0.2 FOO.domain FOO That instantly solved the problem.

share|improve this answer

Check

host 'hostname'

get quick result MC use hostname at first to connect to internal service

In similar situation on Fedora 18 I add hostname to /etc/hosts and it help.

share|improve this answer
    
mc internal service? may be we could change some configuration to fix mc to not require changing /etc/hosts? or is the /etc/hosts broken and mc expects it to be corrected? –  Aquarius Power Jan 22 at 21:20
    
oh, I just found that this works here: alias mc='TERM=linux mc' –  Aquarius Power Jan 22 at 21:29
    
Really /etc/hosts is broken, from some point of view. Impossible to resolve own hostname to own ip. I don't know why mc depend on it there. –  mmv-ru Jan 22 at 22:32

Try to delete line "search whatever.something" from /etc/resolv.conf

/etc/hosts should have the lines:

127.0.0.1 localhost

127.0.0.2 hostname.domain hostname

"hostname" is your hostname and "domain" is your domain.

share|improve this answer
    
That makes some sense only if the machine is never connected to the 'net. That file is filled in by DHCP (or when the Internet connection is configured). –  vonbrand Jan 26 '13 at 3:38

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.