Git development
 help / color / mirror / Atom feed
From: Johannes Schindelin <Johannes.Schindelin@gmx.de>
To: Gyandeep Singh <gyandeeps@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: Bug: Cannot kill Nodejs process using ctrl + c
Date: Wed, 28 Jun 2017 16:40:20 +0200 (CEST)	[thread overview]
Message-ID: <alpine.DEB.2.21.1.1706281527120.84669@virtualbox> (raw)
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

  parent reply	other threads:[~2017-06-28 14:40 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CAHaNChewK_4a7sPgZqWTNSmchiSbKOJUrpCrGLmcnR+cw6J5qw@mail.gmail.com>
2017-06-26 20:45 ` Bug: Cannot kill Nodejs process using ctrl + c Gyandeep Singh
2017-06-27  2:55   ` Stefan Beller
2017-06-27  3:08     ` Gyandeep Singh
2017-06-27  3:15       ` Stefan Beller
2017-06-27  3:17         ` Gyandeep Singh
2017-06-28 14:40   ` Johannes Schindelin [this message]
2017-06-29 20:12     ` Johannes Schindelin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.DEB.2.21.1.1706281527120.84669@virtualbox \
    --to=johannes.schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=gyandeeps@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox