git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Bug: Cannot kill Nodejs process using ctrl + c

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Jun 28, 2017, 14:40 UTC
Message-ID
<alpine.DEB.2.21.1.1706281527120.84669@virtualbox>
In-Reply-To
<CAHaNChecHzZqzafe4P85Kz4BtJuisO+krCvm=yPW9wGMXWJK_A@mail.gmail.com>
Hi,
On Mon, 26 Jun 2017, Gyandeep Singh wrote:
> 3. hit "CTRL + c" (2 times) to kill the process.
> 4. 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 way Ctrl+C is handled in Git for Windows changed recently, indeed.
Remember: sending signals to processes to ask them to terminate is *POSIX*
semantics. Not Windows semantics.

On Windows you can terminate a process via the Win32 API. And I really mean "terminate". There is no chance for that process to, say, remove a now-stale .git/index.lock.

We have to jump through hoops to accomodate Git's lack of non-POSIX understandings. In this particular case, we inject a remote thread into the process, running ExitProcess() so that the atexit() handlers have a chance to perform the cleanup that Git so cleverly expects to be able to do when being terminated.

It is probably that thread that is still trying to run when you hit Ctrl+C the second time, and that second time it terminates *just* the shadow process: node.exe is a Console program, and since you run it in Git Bash (which does not have a Win32 Console, but emulates a Unix terminal instead) the node shell alias runs node.exe through a helper called winpty.exe that I suspect gets terminated without taking down its child processes.

Ciao, Johannes

Previous: Gyandeep SinghNext: Johannes Schindelin
Message 6 of 7 in “Re: Bug: Cannot kill Nodejs process using ctrl + c”
  1. Gyandeep SinghJun 26, 2017
  2. Stefan BellerJun 27, 2017
  3. Gyandeep SinghJun 27, 2017
  4. Stefan BellerJun 27, 2017
  5. Gyandeep SinghJun 27, 2017
  6. Johannes SchindelinJun 28, 2017
  7. Johannes SchindelinJun 29, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.