I have been using Cygwin commands from my Windows CMD prompt for several months without problems. Within the past few days, every time I call a Cygwin command (ls
for example), the command takes several seconds to "load" before it actually runs. If I try the same command from within a bash prompt, it runs ("loads") immediately.
The Cygwin FAQ mentions that network drives in PATH may cause problems, so I've tried some permutations of my PATH
variable and network connectivity. Below, "full PATH
" means my original path setting; "short PATH
" means the path with only the Cygwin bin directory. Times are reported through the time
command.
ls
Connected to network:
ls
within bash
: 0.124 sls
within CMD (full PATH
): 41.29 sls
within CMD (short PATH
): 38.56 sDisconnected from network:
ls
within bash
: 0.125 sls
within CMD (full PATH
): 0.17 sls
within CMD (short PATH
): 0.19 scygcheck
I ran cygcheck -s
and noticed:
Warning: There are multiple cygwin1.dlls on your path
although this may be due to running cygcheck
from within Cygwin's bin
directory. I completely uninstalled and reinstalled Cygwin and still see the same issue.
netstat
I ran netstat -a -n
before executing Cygwin's ls
and after execution (while it is stalled). I did this several times and found one line from each run that appeared consistently during the delay:
UDP 127.0.0.1:55030 *:*
The port number changed from test to test.
strace
resultsI ran Cygwin's strace
on the ls
command. Most of the delay is spent in calls such as:
11685 886560 [main] ls 10020 pwdgrp::fetch_account_from_windows: line: <xxxx>
and
12684 899244 [main] ls 10020 cyg_ldap::fetch_ad_account: No entry for (objectSid=\00\00\00\00) in xxxx DC=xxxx,DC=xxxx,DC=xxxx
Trim down your Windows PATH (to the bare bones like %SystemRoot%\system32;%SystemRoot%) Remove things you don't need from bashrc and bash_profile. Move things you only need in your terminal window from bashrc to bash_profile. One surprisingly large time suck in Cygwin is Bash completion.
Due to limitations of Windows and the NT kernel, Cygwin is often a lot slower than Linux when running, and one particular slowdown is due to the complex way Cygwin has to emulate the Linux fork() call.
Use -f to terminate native Windows processes not started by Cygwin processes. -f can also be useful to terminate Cygwin processes not answering to SIGKILL. Unless you specific the -W option, the "pid" values used by kill are the Cygwin pids, not the Windows pids.
A section in Cygwin's FAQ addresses slow startup times. Cygwin recently changed to using Active Directory lookups for authentication, rather than using flat files. Changing the defaults in /etc/nsswitch.conf
from
passwd: files db
group: files db
to
passwd: files
group: files
skips the AD lookup. My Cygwin commands are now speedy again.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With