'git bash: why does bash on Windows start a new instance of itself in order to run an external command?

If you start git-bash and monitor bash.exe with procmon, you will see that just running a simple command like clear starts a new instance of bash.exe. This instance doesn't stick around for the lifetime of the external command - it is started and almost immediately terminates. Thus if you type grep hello you will see that although the grep process is still running the additional bash.exe process terminates.

Is there a reason bash launches a new bash.exe process and is there any way to change this behaviour? It causes performance problems in certain environments were antivirus software is checking every process that starts: one more process is another half-second delay.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source