-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug: Cannot kill Nodejs process using ctrl + c #1219
Comments
So this has been reported to the Git mailing list: https://public-inbox.org/git/CAHaNChecHzZqzafe4P85Kz4BtJuisO+krCvm=yPW9wGMXWJK_A@mail.gmail.com/t/#m014eb20edd8dbe7f0bd41527f031c7e578747d9e And I responded there, too: On Mon, 26 Jun 2017, Gyandeep Singh wrote:
The way Ctrl+C is handled in Git for Windows changed recently, indeed. Remember: sending signals to processes to ask them to terminate is POSIX On Windows you can terminate a process via the Win32 API. And I really We have to jump through hoops to accomodate Git's lack of non-POSIX It is probably that thread that is still trying to run when you hit Ctrl+C |
is the decision that the behavior present in |
@dscho Just wanted to check-in to understand whether this is something considered a bug and will be fixed in future or this is the expected behavior? thanks |
ping... |
The previous behavior was to terminate processes instead of killing them, I.e. now processes get a chance to clean up before exiting.This fixed the very real bug that It is not clear from your description what goes wrong, as information such as "bitness" of the node.js let alone instructions how to reproduce this issue easily & quickly is missing. |
I am sorry but i think I have given the instruction in the issue (Details -> Steps). What are you looking for other than that? |
Time. |
I am having the same issue. if I run either of these scripts in PowerShell, "scripts": {
"start": "nodemon --watch views --watch public --watch routes ./bin/www ",
"test": "karma start karma.conf.js --no-single-run" The start script is starting up an expressjs web app. When I type The test script will respond to a |
Is this running as a 32-bit or as a 64-bit process? |
Nodejs is 64-bit if that is what you mean. |
What I meant is the process (even 64-bit software is know to execute 32-bit code from time to time, e.g. Git for Windows' installer is always 32-bit). But I guess 64-bit node.js will run 64-bit processes. Hrm. Can you |
Having the same issue using latest Git for Windows |
@dscho Attempting to kill the process with or without the |
@zaggino please do not claim that this fixes the problem. It does nothing of the sort, it is just a workaround, nothing more. I understand that it is much harder to fix this, or even to help fix this, than to revert to a previous version, but it really helps nobody to paper over the issue.
@begin-again this, in contrast, is helpful. Maybe (hopefully?) if you can call |
$ ps -W | grep node
11076 0 0 11076 ? 0 14:33:16 C:\Program Files\nodejs\node.exe
13032 0 0 13032 ? 0 14:33:17 C:\Users\me\Projects\connect-client\node_modules\phantomjs-prebuilt\lib\phan
tom\bin\phantomjs.exe
02:37:34 ~
$ kill 11076
0 [main] bash 15856 cygwin_exception::open_stackdumpfile: Dumping stack trace to bash.exe.stackdump The process remained running. Stack trace $ cat bash.exe.stackdump
Stack trace:
Frame Function Args
000FFFFAF30 0018005D31C (000FFFFE3F4, 56240100000080, C0C0C000F0EDEE, 000FFFFDE50)
000FFFFAFD0 0018005E91B (00000000064, 00000000000, 00000000000, 00000000000)
000FFFFB220 00180121DA0 (00000000000, 0060003A229, 0000000065C, 00000000004)
000FFFFBBC0 0018005D651 (00180040000, F84C005C0000, 000FFFFB5C0, 000FFFFB570)
000FFFFB5C0 7FFC7523AB6D (000FFFFBBC0, 00000000000, 001CD61B6EC, 00174AE0001)
000FFFFB5C0 7FFC751D9933 (000FFFFC4E0, 00000002B44, 001800B3A62, 00000000002)
00000000000 7FFC75239C8A (00000000000, 001005EC610, 001004E6EF1, 0010043CB4E)
00000000000 001800EB190 (001005EC610, 001004E6EF1, 0010043CB4E, 00000000000)
00000000000 0018011E752 (00600199D00, 00000000000, 00000000000, 00000000000)
000FFFFC640 0018011ECB9 (006001D7171, 001005EB004, 00000000003, 00000000009)
000FFFFC640 0018011EE21 (006001CCA60, 0060019A800, 0010040E508, 00600227F30)
000FFFFC640 0018011A58B (006001CCA60, 0060019A800, 0010040E508, 00600227F30)
000FFFFC640 00100427D41 (00000000020, 00000000004, 001005EC5B0, 00000000000)
000FFFFC640 001004607F8 (00100410FBB, 00600043580, 00600199BD0, 00000000000)
00000000000 001004142AA (0060000001F, 001004E494B, 001800BA3D3, 00600000000)
00000000000 00100416707 (001FFFFFFFF, 001FFFFFFFF, 00000000000, 006001D5EF0)
End of stack trace (more stack frames may be present) |
Some of my node processes do respond properly to |
FWIW I just tried this with my (32-bit) node.js v6.10.2 that I installed ages ago, and hitting Ctrl+C once. It did terminate the process correctly. |
And now I downloaded the 64-bit .zip from https://nodejs.org/dist/v8.5.0/node-v8.5.0-win-x64.zip and tried again. Same result. A single Ctrl+C terminates the process correctly. |
@dscho with
running
run
|
Sorry, it does kill things here... me@work MINGW64 /d/test-git/nodejs-ctrl-c-1219
$ git --version
git version 2.14.1.windows.1
me@work MINGW64 /d/test-git/nodejs-ctrl-c-1219
$ node --version
v8.5.0
me@work MINGW64 /d/test-git/nodejs-ctrl-c-1219
$ npm --version
5.3.0 Actually, and that's funny, a second attempt reproduces the problem:
|
So I think what is happening is a subtle change in behavior introduced by the change to the MSYS2 runtime that made it into v2.13.1 and was announced thusly;
The subtle change is that the responsibility to signal child processes was moved from the caller of |
I had an issue with this where I thought it was Node: nodejs/node/issues/16103 It has to do with MinTTY (which, as you just mentioned, likely has to do with MSYS2). I reinstalled Git with the following settings and
Obviously, switching to CMD doesn't solve the fact that MinTTY is doing this, but for me, it is fine for now. I hope this helps. |
Hi all, so I experienced the same issue lately and as indicated here zombie processes were present when launching node in the git bash terminal MinTTY - launched from the default Git Bash shortcut and from the context menu on a folder - located in C:\Program Files\Git Hope this helps. |
Having the same issue here. Switching away from MinTTY let me end processes normally with Ctrl+C |
@gyandeeps I have a lot of sympathy for your situation. But please also see mine: there are tons of open tickets here. Some of them describe really hard-to-solve problems (last time I dove into MSYS2 issues, it took me three days, straight, to just understand the issue, that's how hard MSYS2 things are to debug, and in those three days I could not address any other issues on the bug tracker). Some of them describe really easy-to-solve problems, yet it still is me who ends up having to address them. Y'all are not helping here. So what I face is simply a question of priorities: can I really afford to spend another three days straight (during which time I cannot take care of other issues, which then weigh on my shoulders) to address a problem that seems to affect only node.js users, not Git users in general? I hope you see that this is a serious problem. Of course, if you would jump in and help, you would get what you want. Quicker. A lot quicker. As things stand, I cannot guarantee to even get to this bug this year. I have a long backlog of issues I have to work on, and the Ctrl+C issue is way far down. |
Sorry to come off so needy. And I do understand you situation and thanks you for all your efforts. I just wanted to make sure that this issue does or doesnt fall under "will not be fixed" bucket since some of the discussion (way up top) led me to believe that. |
@gyandeeps if you have some rudimentary C skills, you could help me fix it. I know how to fix it, I simply lack the time. Do you have time? |
I did little bit C back in 2006 but never done it after that. If you can give me some pointer then I can try. |
The MSYS2 runtime (which is responsible for handling Ctrl+C) is actually written in C++... Have a look here: git-for-windows/msys2-runtime@0b90c6a What needs to be changed in this commit is the way To get started with this, please see https://github.com/git-for-windows/git/wiki/Building-msys2-runtime It will be a ride, but I can assist. |
@dscho I'd be willing to give this a shot. I've been able to successfully rebuild
So I might write a function similar to
The main thing I'm not following here is where Let me know if I'm understanding this correctly if you get a chance. Thanks! |
You have no idea how thankful that makes me. I've been agonizing about this, as I realistically lack the time.
Oh, there is no need to introduce another function there. Just modify Then, just pass different callback functions for SIGINT, SIGTERM and SIGKILL. To be honest, I am not quite sure what to do in the SIGINT case, but I am fairly certain that it should perform that The SIGTERM case definitely should use that The SIGKILL case should run
What I mean is that Cygwin/MSYS2 processes do not want to be handled this way. They have their own signal processing (triggered via I am pretty excited that you take care of this! |
@dscho thanks for clarifying. Here's my first attempt at it There's still some cleanup/commenting to do, but let me know what you think of what I have so far. This version seems to handle the node.js example described in this issue, but it's possible it's just falling back to Just a heads up - I have only minimal c++ experience |
@afsmith92 That looks really good! Now we only need your signoff (i.e. a |
@dscho I updated the commit message and fixed the indentation issue: afsmith92/msys2-runtime@574b7ec A couple things:
|
I assume you copied the
Oh, that only applies to patches for https://github.com/git/git. In Git for Windows, we're happy to accept the much easier Pull Requests. Thanks! |
Yup, should be good to go if there are no other comments on the PR. I'll squash the commits when you're ready to merge. |
Thanks, I already did that ;-) |
👍 Thanks for figuring out the fix! |
Has anyone tested this against Maven? Both mvn and mvnDebug seem to ignore CTRL-C for me now that I upgraded to the latest Git for Windows. Super appreciate the work you guys have done on this so far. |
@ozymandias13 See #1470 |
@ozymandias13 if you had chipped in like @afsmith92 did, you'd have gotten a fix a lot sooner. In fact, @afsmith92's work even made it much easier for me to come up with a fix for this (which is the same fix as for #1491). A new snapshot should be available at https://wingit.blob.core.windows.net/files/index.html soon, and you could help at least by testing it. |
I did test it and it still isn't working with mvn or mvnDebug. I hope the feedback is helpful. Sorry I couldn't help more - not sure where to start, but I very much appreciate your effort on this. I'm not trying to put any pressure on you to get it working, just thought the feedback would be helpful. |
@ozymandias13 while I appreciate your test, this here ticket is not about Maven, it is about node.js. So in order to verify that closing it was appropriate, I really would like to hear back from node.js users. |
(And yes, I realize that I addressed you personally, that was a mistake. I still want you to go ahead and put more effort in to see your issue fixed, but please over in #1470.) |
Completed solved my issue with Git Bash and Node and processes running on ports after Ctrl + C, thank you so much |
Setup
Windows 7
defaults?
to the issue you're seeing?
Details
Bash
Minimal, Complete, and Verifiable example
this will help us understand the issue.
Steps:
its a simple server running on 3000 port.
still running. or if you try to restart the server it will say port
300 already in use.
If you look at taskmanager, then you will see a node.js process still running. or if you try to restart the server it will say port 300 already in use.
The nodejs process still running.
Notes:
The text was updated successfully, but these errors were encountered: