Git Product home page Git Product logo

Comments (52)

tateman74 avatar tateman74 commented on May 8, 2024 7

Getting the same thing guys with a node or nodemon process. Dies and leaves the process running. I'm running Node 8.2.1 so there is no fix with a node upgrade. This is a Bash issue with Windows 10 only. I'm going to have to use a different shell now as I can't keep hunting down the node process to kill it.

screen shot 2017-08-01 at 11 07 49 am

from node-pty.

slavik57 avatar slavik57 commented on May 8, 2024 7

Same here...

I have a simple express app that listens on some port...
When I run it with node server.js it passes the CTRL+C to it and terminates it
When I run it with npm start when the start is "start": "node server.js" and press CTRL+C it hangs...

I noticed that when running with default windows command line it doesn't happen...

git --version outputs: 2.13.3.windows.1

from node-pty.

melgish avatar melgish commented on May 8, 2024 6

Observed similar behavior running live-server. Also noticed that sometimes CTRL-C works but only after a lengthy timeout.

from node-pty.

Tyriar avatar Tyriar commented on May 8, 2024 4

Sending ^C to gulp watch sometimes seems to do nothing, however ^C does work in general. Not sure why atm.

from node-pty.

sedulous-mortal avatar sedulous-mortal commented on May 8, 2024 3

I was able to get all my node processes to die directly from the Git Bash shell on Windows 10 by typing taskkill -F -IM node.exe - this ends all the node processes on my computer at once. I found I could also use taskkill //F //IM node.exe. Not sure why both - and // work in this context. Hope this helps!

from node-pty.

SharakPL avatar SharakPL commented on May 8, 2024 3

Don't know about NodeJS but exitig git log with ctrl+c bugs the terminal completely. It's not VSCode related or even console related because the same thing happens for me in Git-bash (mingw64), Powershell and CMD in windows, even outside VSCode. It must be one of Git's dependency that is also used by Node... or it's just windows saying I don't like Git :)

from node-pty.

Tyriar avatar Tyriar commented on May 8, 2024 2

@haxor211 I'm hoping the fix for microsoft/vscode#45693 will do the trick, I'll be working on that probably in the next few months.

from node-pty.

slavik57 avatar slavik57 commented on May 8, 2024 1

@sigod seems like it's time to git bisect the problem

from node-pty.

Tyriar avatar Tyriar commented on May 8, 2024 1

Weird things happen when exiting git log via ctrl+c as well, see microsoft/vscode#39419

from node-pty.

parkovski avatar parkovski commented on May 8, 2024 1

I've confirmed (by tracing API calls) that this stems from a bug in cmd.exe - rprichard/winpty#116 (comment)

Winpty's handling doesn't cover unprocessed mode last time I checked, but I think that's just from the confusion around cmd. Hoping there's a way to set the keyboard state for cmd, otherwise it'd have to be fixed by MS or hook an API call.

from node-pty.

janacm avatar janacm commented on May 8, 2024 1

Quick solution for NodeJS issues: use powershell as an external terminal

from node-pty.

saostad avatar saostad commented on May 8, 2024 1

I find what was my problem.
for some reason I had this in my settings:
"terminal.integrated.rendererType": "dom"
after I remove it it start working and it's much faster

from node-pty.

gpmetheny avatar gpmetheny commented on May 8, 2024 1

@Abdurraheem @SharakPL @sashberd

I had the same issue.
GitBash - git version 2.16.2.windows.1

When I use e.g. git log command and press ctrl+c the console is stuck. I could type, but no command are typing. However, after press enter the command is running.But I got solution ,after git log , press wq to exit from the log and now my console cursor is visible and and command is also visible now.

I was having the same problem specifically with git log, but that's because it uses less. I didn't try wq, but I'm exiting cleanly using q (NOT ctrl + q). Able to continue typing commands as normal.

*** answer found here ***

from node-pty.

NischalSehrawat avatar NischalSehrawat commented on May 8, 2024 1

CTRL+ALT+M

from node-pty.

Syllinger avatar Syllinger commented on May 8, 2024

Also having an issue with Ctrl-C where the current process is not halted, instead the terminal is closed/crashes and all running processes exit in unison.

  • VSCode Version: 1.7.1
  • OS Version: Windows 10 Home

from node-pty.

Tyriar avatar Tyriar commented on May 8, 2024

@Syllinger If you see that again can you go to Hep > Toggle Developer Tools, open the console and grab a screenshot and/or paste the error?

from node-pty.

CherryDT avatar CherryDT commented on May 8, 2024

As mentioned in the VSCode issue already: This happens to everybody in our company as well. However it also happens to outside VSCode, I have to add. We use ConEmu, so maybe the issue exists in general with the combination of Git Bash, npm/node and non-default console emulators?

This makes me wonder who is really at fault here, it could be very well the MSYS bash or node for Windows...

from node-pty.

CherryDT avatar CherryDT commented on May 8, 2024

In fact it sounds like Maximus5/ConEmu#402 and git-for-windows/git#227

from node-pty.

vladbalanescu avatar vladbalanescu commented on May 8, 2024

Any updates on this issue guys? I am currently running a continuous Casper script in my bash shell on Windows and I cannot stop the execution other than after finishing the promise chain execution.

from node-pty.

IanOvenden avatar IanOvenden commented on May 8, 2024

Hey @vladbalanescu - although not perfect within VSCode, I did find that upgrading to latest version of Node allowed me to terminate most processes 👍

from node-pty.

vladbalanescu avatar vladbalanescu commented on May 8, 2024

Hey @IanOvenden which version of node are you using? I am currently on 7.10 and whenever I am running a casperjs script I cannot stop it unless it finished execution and the promise chain finished returning

from node-pty.

IanOvenden avatar IanOvenden commented on May 8, 2024

@vladbalanescu - I'm currently running on version 6.11.1, which is the latest stable release. At the time I was having issues, I was on 4.x.x and upgraded to an early version of 6 - I can't remember exactly which versions I moved from.

from node-pty.

kucukkanat avatar kucukkanat commented on May 8, 2024

@slavik57 this is very useful information thanks

from node-pty.

parkovski avatar parkovski commented on May 8, 2024

I’ve been trying to figure this one out and it’s pretty baffling but I’ve got a bunch of info that may help.

The problem is in winpty, src/agent/ConsoleInput.cc around line 400 where it generates a Ctrl C event. Powershell is easy - PSReadLine disables processed mode and responds to the ^C character. All you have to do is WriteConsoleInput a \x03 and it will work. This has to happen unconditionally though, the processed mode check in winpty makes it not work somehow.

The one that’s got me stuck, and I’ve spent hours in windbg on this, is cmd. Its input loop is basically call ReadConsole and check a global flag if a Ctrl C was generated during the call. Then in another thread, it has a control event handler that sets the flag when the system event is triggered. From the disassembly it looks like it should happen when you call GenerateConsoleControlEvent, but it doesn’t. Or rather, the event clearly goes through, because I can get a “terminate batch job” prompt, but pressing it again does nothing, and it doesn’t work for the regular prompt either. The system frustratingly does something different when a debugger is active so it’s really hard to track this one down.

To get this to work on top of what I have working (using calling GenerateConsoleCtrlEvent and sending a \x03), all that’s left is to get cmd to recognize the event when it’s in a prompt.

A possible hint is that cmd normally prints two new lines after an actual Ctrl C press, but if you disable processed mode it only prints one. So somehow I think there are two separate checks for this and I’m missing both of them.

from node-pty.

parkovski avatar parkovski commented on May 8, 2024

After a bit more looking at the disassembly, there clearly are two checks. The first is in Handler, the Ctrl-C/Break handler, which is frustratingly really straightforward. The very top of the function essentially says if (ecx < 2) SetCtrlC(); where ecx is the control code - 0 and 1 are Ctrl-C and Ctrl-Break.

The other check is for the actual character \x03 as it's reading the console buffer into the lexer buffer. There is something going on with a key flag and a data flag that I'm not sure of though, and it's pretty hard to follow because it uses setjmp/longjmp and frequently jumps to this big block of code soup called chkstk that's just a bunch of random pieces of other functions.

from node-pty.

sigod avatar sigod commented on May 8, 2024

git --version outputs: 2.13.3.windows.1

2.14.2.windows.2 — the same issue.
2.13.0.windows.1 — the issue isn't present.

from node-pty.

yayayahahaha avatar yayayahahaha commented on May 8, 2024

git version 2.14.3.windows/1
same issue

from node-pty.

parkovski avatar parkovski commented on May 8, 2024

Right now I’m hoping that OpenSSH fixes this - PowerShell/Win32-OpenSSH#914 - and that whatever they do also works for winpty, because I spent a lot of time disassembling conhost and cmd and still couldn’t get it working. Windows generates an SEH exception instead when a debugger is attached so it’s really hard to tell what would trigger it without a debugger. I’ve tried stepping into kernel32 and undoing the debugger check too and still no luck.

My current solution is to patch node-pty’s winpty DLL with one that sends WM_KEYDOWN for Ctrl-C, which works for VSCode on Win10 but is not a general solution for winpty.

WinRS supposedly supports this if anyone is up for the disassembly challenge, but other than that I’m out of ideas.

from node-pty.

zeus2198 avatar zeus2198 commented on May 8, 2024

You can end the process using the command taskkill /F /IM node.exe, for convenience just create a .bat with the above command and save it on the desktop and run it whenever you need to stop the process.

from node-pty.

parkovski avatar parkovski commented on May 8, 2024

Right, the problem is taskkill tells the kernel to stop the process. If a program catches SIGINT or CTRL_C_EVENT, they can do cleanup first, or sometimes (shells for example) it’s not even appropriate for them to quit. The core problem here is while it’s hard but not impossible to send that to an arbitrary process on Windows, cmd.exe seems to ignore it unless it comes from conhost, which makes it hard to write a decent terminal emulator.

from node-pty.

parkovski avatar parkovski commented on May 8, 2024

That's reproducible in the regular console using this utility - turn off processed input using isvt -p (pid of shell process running git log) i=_-ENABLE_PROCESSED_INPUT, then type ^Z ^C in the git log window. The git process exits but it's leaving behind the less process it spawned, although I'm not sure exactly which part of that sequence of events causes it.

from node-pty.

cScarlson avatar cScarlson commented on May 8, 2024

Same. Child process doesn't close. I switch my server's port a few times, and then have to manually search & destroy the processes -- or only lift my server using Command Prompt. I've seen older git-issues of this problem. Just update Git from 2.6.x to 2.15.1 assuming this was critical enough to be fixed by now.

git --version: 2.15.1.windows.2 (Windows 10 | 64)
node -v: v8.9.3

from node-pty.

florian-kittel avatar florian-kittel commented on May 8, 2024

I have the same issue. I tried it today with the latest git update to 2.16.0.

It now cancels my node js (server and angular cli) applications in a git bash, but I have still the issue at an angular application running in a bash terminal at VS code. It takes 30 seconds or more to cancel.

from node-pty.

sashberd avatar sashberd commented on May 8, 2024

I think I have the same issue.
GitBash - git version 2.16.2.windows.1

When I use e.g. git log command and press ctrl+c the console is stuck. I could type, but no command are typing. However, after press enter the command is running. It is like "enter password" behavior when you enter password but no symbols are seen

Will glad to get any solution to this strange behavior after I updated git to 2.16

from node-pty.

Mellbourn avatar Mellbourn commented on May 8, 2024

I think I have the same issue in tmux terminal inside VSCode on MacOS.

I have the setup that was described by João Moreno (@joaomoreno) in his blog post https://medium.com/@joaomoreno/persistent-terminal-sessions-in-vs-code-8fc469ed6b41

However, it seems to me that Control-C, does not work as good as it used to.

It is particularly noticeable when I run nodemon. When I run it in tmux in iTerm, I can exit the run without problem by using Control-C. If I run nodemon inside tmux inside VSCode, I cannot. Instead it just renders ^C in the terminal window.

  • VSCode Version: 1.21.1 and 1.22.1-insiders b75321329388d74e34f79dcfcb789246e31836a8
  • OS Version: MacOS 10.13.3

Does this issue occur when all extensions are disabled?: Yes

from node-pty.

Tyriar avatar Tyriar commented on May 8, 2024

@Mellbourn that's definitely not this issue as this is Windows only, we can follow up in a VS Code issue if you want to create one https://github.com/Microsoft/vscode

from node-pty.

Mellbourn avatar Mellbourn commented on May 8, 2024

@Tyriar Right. I've reported the problem here now: microsoft/vscode#46731

from node-pty.

dieselVtwin avatar dieselVtwin commented on May 8, 2024

Hi all,
I just bumped into this issue, but without VS Code involved in the mix.

If this is only an issue on Windows platforms, as @Tyriar states, then I think it is actually under VS Code and in the Bash shell included in GIT for Windows. It's discussed in issue 1491.
git-for-windows/git#1491

A Linux engineer that I worked with helped this poor Windows engineer to work around it with the magical phrase, "stty echo", to turn the keyboard echo back on.

Cheers,
dVt

from node-pty.

Abdurraheem avatar Abdurraheem commented on May 8, 2024

I had the same issue.
GitBash - git version 2.16.2.windows.1

When I use e.g. git log command and press ctrl+c the console is stuck. I could type, but no command are typing. However, after press enter the command is running.But I got solution ,after git log , press wq to exit from the log and now my console cursor is visible and and command is also visible now.

from node-pty.

parkovski avatar parkovski commented on May 8, 2024

Hey @Abdurraheem I believe that’s actually a git bug, try killing all processes named less after you get out of the git log.

from node-pty.

haxor211 avatar haxor211 commented on May 8, 2024

So it this ever gonna get fixed? Or Im doomed to use taskkill /im node.exe /f forever?

from node-pty.

saostad avatar saostad commented on May 8, 2024

I have same problem with git bash, but after press ctrl+c, if I wait like 5 minutes it will stop the "npm start" process for me.
I am using create-react-app typescript package
but if I use "docker-compose up" to run my docker container after I press ctrl+c it stop the container without problem.

from node-pty.

pikilon avatar pikilon commented on May 8, 2024

"terminal.integrated.rendererType": "dom"

False alarm, it doesn´t make it more responsive.

from node-pty.

luohong123 avatar luohong123 commented on May 8, 2024

I am experiencing the same problem, when I press CTRL+C, the editor unexpectedly quits, appears 3221225786, my solution is to upgrade the git tool, the following is my git version

git --version
// git version 2.23.0.windows.1

The issue has been resolved after the upgrade

from node-pty.

tohagan avatar tohagan commented on May 8, 2024

If you start another bash shell inside the bash started by VSCode then I found that apps you start in the inner shell DO respond to Ctrl-C.

from node-pty.

rileyhemp avatar rileyhemp commented on May 8, 2024

If you're still experiencing this, run git update-git-for-windows

from node-pty.

FiruzzZ avatar FiruzzZ commented on May 8, 2024

I have this issue with 2.25.1 (just updated from 2.25.0) to check if it was already fixed but no.
CTRL+C on Gitbash works with commands like:
ping xxx.xxx.xxx //t
but doesn't work with git log or git diff, I have to press ENTER a few time after pressing CTRL+C and even after this, it takes a few seconds to the interrupt the command

Update: just pressing Q does the trick, this was always possible? I didn't know

from node-pty.

Tyriar avatar Tyriar commented on May 8, 2024

@FiruzzZ fyi in bash, git log/diff aren't meant to exit with ctrl+C,.

from node-pty.

setebe avatar setebe commented on May 8, 2024

The temporary solution for me:

image

from node-pty.

SharakPL avatar SharakPL commented on May 8, 2024

@setebe I think much better solution is to simply remember to use Q instead of Ctrl C in scrollable parts like git log output. Besides I've just checked and using Ctrl C while viewing git log does nothing in powershell and cmd. You must use Q to quit log so this has been fixed already.

I'm using Git for Windows 2.25.1.windows.1 (64bit)

from node-pty.

setebe avatar setebe commented on May 8, 2024

@SharakPL I've downgraded to version 2.8.1 and ctrl+c starts to work.

from node-pty.

Tyriar avatar Tyriar commented on May 8, 2024

ctrl+c is not meant to work in git log/diff, downgrading is not recommended as you'll probably hit other bugs that have been fixed in it. Anyway this issue is long fixed with the move to conpty so this discussion is off topic.

from node-pty.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.