Git bash 错误:无法分叉子进程:没有可用的终端 (-1)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/45799650/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 05:06:23  来源:igfitidea点击:

Git bash Error: Could not fork child process: There are no available terminals (-1)

gitterminalgit-bash

提问by A. Petrizza

I have had up to 8 git bash terminals running at the same time before.

我之前有多达 8 个 git bash 终端同时运行。

Currently I have only 2 up.

目前我只有2个了。

I have not seen this error before and I am not understanding what is causing it.

我以前没有见过这个错误,我不明白是什么导致了它。

Any help would be appreciated!

任何帮助,将不胜感激!

Picture attached:

附图片:

enter image description here

在此处输入图片说明

采纳答案by Scott Newson

Found a similar issue and solution in google groups

google 群组中发现了类似的问题和解决方案

I opened a windows command prompt and ran the command

$ tasklist

It looks as though the ssh connections I had made in my git bash shells weren't being closed when those windows were closed and were hanging the available git bash shell windows.

This may be a dangerous solution but from the windows command prompt I ran

$ taskkill /F /IM ssh.exe 

Everything appears to be working again after this. It may not have directly been an issue of orphan processes, but this worked for at least for me.

我打开了一个 Windows 命令提示符并运行了命令

$ tasklist

当这些窗口关闭并挂起可用的 git bash shell 窗口时,看起来好像我在 git bash shell 中建立的 ssh 连接没有关闭。

这可能是一个危险的解决方案,但我从 Windows 命令提示符运行

$ taskkill /F /IM ssh.exe 

在此之后,一切似乎都恢复了。这可能不是孤儿进程的直接问题,但这至少对我有用。

Additional note: you can also kill other processes, for example like:

附加说明:您还可以杀死其他进程,例如:

$ taskkill /F /IM vim.exe

回答by Joe z

I see the problem on windows in git bash when I kill my git bash console without using exit. I found killing ssh-agent.exe task from windows task manager to fix the problem.

当我在不使用 exit 的情况下杀死我的 git bash 控制台时,我在 git bash 中看到了 Windows 上的问题。我发现从 Windows 任务管理器中杀死 ssh-agent.exe 任务来解决这个问题。

回答by Federico Caccia

In my case, it was related with the use of VS code. Previously I have opened VS code using a git bash terminal and executing

就我而言,它与 VS 代码的使用有关。以前我使用 git bash 终端打开 VS 代码并执行

code .

then closing the terminal.

然后关闭终端。

The problem is solved by closing all the VS code windows opened.

通过关闭所有打开的 VS 代码窗口来解决问题。

When you have any editor or IDE configure to open a terminal as git bash, then when the IDE/IDE is running, the git bash will spin up bash from "C:\Windows\System32\bash.exe" and any other attempt to open bash from a separate window is likely to crash.

当您将任何编辑器或 IDE 配置为以 git bash 的形式打开终端时,当 IDE/IDE 运行时,git bash 将从“C:\Windows\System32\bash.exe”和任何其他尝试启动 bash从单独的窗口打开 bash 很可能会崩溃。

The best solution is to kill the IDE/Editor bash and open from a new window or continue from the IDE/Editor command.

最好的解决方案是杀死 IDE/Editor bash 并从新窗口打开或从 IDE/Editor 命令继续。

回答by Return_Of_The_Archons

I address this with a workaround:

我用一个解决方法来解决这个问题:

  1. Close the Git Bash window.
  2. Open Task manager.
  3. Find the 'Git for Windows' process.
  4. Kill it.
  5. Open Git Bash.
  1. 关闭 Git Bash 窗口。
  2. 打开任务管理器。
  3. 找到“Git for Windows”进程。
  4. 杀了它。
  5. 打开 Git Bash。

It should be ok now.

现在应该没问题了。

回答by klimat

To make life easier (this problems happens quite often) create a file called fixbash.batin home directory and paste this:

为了让生活更轻松(这种问题经常发生)fixbash.bat在主目录中创建一个名为的文件并粘贴:

taskkill /F /IM ssh-agent.exe

taskkill /F /IM ssh-agent.exe

When problem occurs just open cmdand type fixbash.batto fix a problem.

出现问题时,只需打开cmd并键入fixbash.bat即可解决问题。

Or

或者

Just paste the taskkill command into your cmdif you don't want to create a script.

cmd如果您不想创建脚本,只需将 taskkill 命令粘贴到您的命令中即可。

回答by andydavies

Restart your machine.

重新启动您的机器。

(The other answers did not work for me. (I didn't try reinstalling. Restarting is probably faster.))

(其他答案对我不起作用。(我没有尝试重新安装。重新启动可能更快。))

回答by The Red Pea

For me (or anyone running protractor, which may spin up a standalone Selenium/WebDriver server), I needed to taskkillthe specific webdriverwhich was running my tests.

对于我(或任何运行量角器的人,它可能会启动一个独立的 Selenium/WebDriver 服务器),我需要运行我的测试taskkill特定 webdriver

So just a different argument: or your chromedriver versionmay vary

所以只是一个不同的论点:或者你的 chromedriver版本可能会有所不同

taskkill /f /im chromedriver_2.34.exe

Note your drivermay vary: IEDriverServer*.*.*.exevs chromedriver_*.**exe

请注意,您的驱动程序可能会有所不同: IEDriverServer*.*.*.exevschromedriver_*.**exe

Your driver may versionmay vary:chromedriver_2.34.exevs chromedriver_2.33.exe

您的驱动程序可能版本可能有所不同:chromedriver_2.34.exevschromedriver_2.33.exe

This problem got worse after protractor quit without closing the automated /test-driven browser, (due to a separate issue I don't yet understand.) Naturally many chromedrivertasks remain running, that's why kill them.

在量角器退出后没有关闭自动/测试驱动浏览器,这个问题变得更糟,(由于一个我还不明白的单独问题。)自然,许多chromedriver任务仍在运行,这就是为什么要杀死它们。

回答by Hari

Open task manager and kill process with name bash, this worked for me.

打开任务管理器并使用名称 bash 杀死进程,这对我有用。

回答by Ishan

This happens when you exit git bash without terminating existing process. Just try and kill those processes that you started from git bash. I was running node process inside git bash, so I killed all node processes Steps to kill

当您退出 git bash 而不终止现有进程时会发生这种情况。尝试杀死那些从 git bash 启动的进程。我在git bash中运行节点进程,所以我杀死了所有节点进程步骤杀死

  1. Open Task Manager
  2. Goto Details Tab
  3. Look for node.exe(you look for you processes)
  4. Kill it each and every node process
  5. Open Git Bash again
  1. 打开任务管理器
  2. 转到详细信息选项卡
  3. 寻找node.exe(你寻找你的进程)
  4. 杀死它每个节点进程
  5. 再次打开 Git Bash

回答by Sonic Soul

finally figured out what was causing this.

终于弄清楚是什么原因造成的。

if we use code like this (explicitly or implicitly) i.e. in .bashrcfile

如果我们使用这样的代码(显式或隐式),即在.bashrc文件中

eval $(ssh-agent -s)
ssh-add ~/.ssh/id_rsa

it spawns a new process.

它产生了一个新的进程。

if you don't exit it and just close the window, that process is still running. so each new bash opened just keeps adding new ones w/out disposing old ones.

如果您不退出它而只是关闭窗口,则该进程仍在运行。所以每次打开的新 bash 都会不断添加新的 bash,而不处理旧的。

when done with a bash window, simply hit ctrl+dor type exitto kill the agent process, and you should not run out of forks.

使用 bash 窗口完成后,只需点击ctrl+d或键入exit即可终止代理进程,并且不会用完叉子。