Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
674 views
in Technique[技术] by (71.8m points)

bash - Git sh.exe process forking issue on windows XP, slow?

Git is essential to my workflow. I run MSYS Git on Windows XP on my quad core machine with 3GB of RAM, and normally it is responsive and zippy.

Suddenly an issue has cropped up whereby it takes >30 seconds to run any command from the Git Bash command prompt, including ls or cd. Interestingly, from the bash prompt it looks likes ls runs fairly quickly, I can then see the output from ls, but it then takes ~30 seconds for the prompt to return. If I switch to the windows command prompt (by running cmd from the start menu) git related commands also take forever, even just to run. For example git status can take close to a minute before anything happens. Sometimes the processes simply don't finish.

Note that I have "MSYS Git" installed as well as regular "MSYS" for things like MinGW and make.

I believe the problem is related to sh.exe located in C:Program FilesGitin. When I run ls from the bash prompt, or when I invoke git from the windows prompt, task manager shows up to four instances of sh.exe processes that come and go.

Here I am waiting for ls to return and you can see the task manager has git.exe running and four instances of sh.exe: Here I am waiting for ls to return and you can see the task manager has git.exe running and four instances of sh.exe

If I ctrl-c in the middle of an ls I sometimes get errors that include:

sh.exe": fork: Resource temporarily unavailable
      0 [main] sh.exe" 1624 proc_subproc: Couldn't duplicate my handle<0x6FC> fo
r pid 6052, Win32 error 5
sh.exe": fork: Resource temporarily unavailable

Or for git status: $ git status

sh.exe": fork: Resource temporarily unavailable
sh.exe": fork: Resource temporarily unavailable
sh.exe": fork: Resource temporarily unavailable
sh.exe": fork: Resource temporarily unavailable

Can I fix this so that git runs quickly again, and if so how?

Things I have tried:

  • Reboot
  • Upgrade MSYS Git to most recent version & Reboot
  • Upgrade MSYS to most recent version & Reboot
  • Uninstall MSYS & uninstall and reinstall MSYS Git alone & Reboot

I'd very much like to not wipe my box and reinstall Windows, but I will if I can't get this fixed. I can no longer code if it takes me >30 s to run git status or cd.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Usually when a program takes 30 seconds to do something that should be instantaneous, it's more likely to be an I/O timeout problem, usually network, rather than the speed of your CPU or the amount of RAM you have. You may wonder how the network is involved, but that's a legitimate question (I wouldn't know for your system either).

Msysgit installs a special prompt that runs a special function __git_ps1 that shows some useful information in the prompt. You can see this using echo $PS1, for my system this shows:

$ echo $PS1
[33]0;$MSYSTEM:w07 33[32m]u@h [33[33mw$(__git_ps1)33[0m] $

This extra information is totally optional and you can turn it off. So try the following in an Msysgit window:

$ PS1='$ '
$

This will reset the prompt to the default $ and not try to run and commands inside the prompt. If this solves your delay problem, then it's likely to be the __git_ps1 function. Try running it manually:

$ __git_ps1
 (master)

and see how long it takes to return.

You can fix this by removing the line that invokes __git_ps1 from C:Program FilesGitetcprofile:

#Comment the lines below
#PS1='[33]0;$MSYSTEM:w07
#33[32m]u@h [33[33mw$(__git_ps1)33[0m]
#$ '

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...