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

7 messages from 2017-06-26 to 2017-06-29. Participants: Gyandeep Singh, Stefan Beller, Johannes Schindelin.
Thread: https://gitlist.dev/t/46264

## Gyandeep Singh, 2017-06-26 20:45

Subject: Re: Bug: Cannot kill Nodejs process using ctrl + c
Message-ID: <CAHaNChecHzZqzafe4P85Kz4BtJuisO+krCvm=yPW9wGMXWJK_A@mail.gmail.com>
URL: https://gitlist.dev/e/CAHaNChecHzZqzafe4P85Kz4BtJuisO%2BkrCvm%3DyPW9wGMXWJK_A%40mail.gmail.com
In-Reply-To: <CAHaNChewK_4a7sPgZqWTNSmchiSbKOJUrpCrGLmcnR+cw6J5qw@mail.gmail.com>

```
Environment:

OS: Windows 7
Git: git version 2.13.1.windows.2
NodeJS: 8.1.2

Steps:

1. Create a js file with content

const http = require('http');
const fs = require('fs');
const port = 3000;
const app = http.createServer((req,res) => {
    res.writeHead(200);
    res.end("hi");
});

app.listen(port);

its a simple server running on 3000 port.

2. Run command "node ./app.js" inside git bash.
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.

Notes:

1. This was working on first version of Git 2.13, it broke after the
first version.


Thanks


Regards,

Gyandeep Singh

```

## Stefan Beller, 2017-06-27 02:55

Subject: Re: Bug: Cannot kill Nodejs process using ctrl + c
Message-ID: <CAGZ79kYR_Vw454RBw7A7ygJdiOauzepVZXBb_CvsCoN9AGE-sA@mail.gmail.com>
URL: https://gitlist.dev/e/CAGZ79kYR_Vw454RBw7A7ygJdiOauzepVZXBb_CvsCoN9AGE-sA%40mail.gmail.com
In-Reply-To: <CAHaNChecHzZqzafe4P85Kz4BtJuisO+krCvm=yPW9wGMXWJK_A@mail.gmail.com>

```
Which exact outputs of Git are invoked?

Does it change when giving slightly different options e.g. --no-pager?

```

## Gyandeep Singh, 2017-06-27 03:08

Subject: Re: Bug: Cannot kill Nodejs process using ctrl + c
Message-ID: <CAHaNChdhg-nHv34-jgumeKw8iJXaXwfY2DAe797nRXPU1VzT3Q@mail.gmail.com>
URL: https://gitlist.dev/e/CAHaNChdhg-nHv34-jgumeKw8iJXaXwfY2DAe797nRXPU1VzT3Q%40mail.gmail.com
In-Reply-To: <CAGZ79kYR_Vw454RBw7A7ygJdiOauzepVZXBb_CvsCoN9AGE-sA@mail.gmail.com>

```
Not sure what you mean by output. But its just goes back to normal like  this

Gyandeep@Gyandeep MINGW64 ~

$



It was working fine on first release of git 2.13. It broken with
releases after that.

Will try with –no-pager flag and let you tomorrow.



Thanks

Gyandeep
Regards,

Gyandeep Singh
Website: http://gyandeeps.com


On Mon, Jun 26, 2017 at 9:55 PM, Stefan Beller <sbeller@google.com> wrote:
> Which exact outputs of Git are invoked?
>
> Does it change when giving slightly different options e.g. --no-pager?

```

## Stefan Beller, 2017-06-27 03:15

Subject: Re: Bug: Cannot kill Nodejs process using ctrl + c
Message-ID: <CAGZ79kZ94Qh4CzCUWNYQQU5EB+Oky13gcp09tBKSYoCaFvqOuA@mail.gmail.com>
URL: https://gitlist.dev/e/CAGZ79kZ94Qh4CzCUWNYQQU5EB%2BOky13gcp09tBKSYoCaFvqOuA%40mail.gmail.com
In-Reply-To: <CAHaNChdhg-nHv34-jgumeKw8iJXaXwfY2DAe797nRXPU1VzT3Q@mail.gmail.com>

```
I miss-read your email.

So you are not running Git, but only talk about the (Git-)bash that is
conveniently bundled with Git for Windows?
For that I recommend https://github.com/git-for-windows/git/issues/new

Johannes Schindelin the GfW maintainer is cc'd here as well, but
AFAICT he prefers Github issues.

On Mon, Jun 26, 2017 at 8:08 PM, Gyandeep Singh <gyandeeps@gmail.com> wrote:
> Not sure what you mean by output. But its just goes back to normal like  this
>
> Gyandeep@Gyandeep MINGW64 ~
>
> $
>
>
>
> It was working fine on first release of git 2.13. It broken with
> releases after that.
>
> Will try with –no-pager flag and let you tomorrow.
>
>
>
> Thanks
>
> Gyandeep
> Regards,
>
> Gyandeep Singh
> Website: http://gyandeeps.com
>
>
> On Mon, Jun 26, 2017 at 9:55 PM, Stefan Beller <sbeller@google.com> wrote:
>> Which exact outputs of Git are invoked?
>>
>> Does it change when giving slightly different options e.g. --no-pager?

```

## Gyandeep Singh, 2017-06-27 03:17

Subject: Re: Bug: Cannot kill Nodejs process using ctrl + c
Message-ID: <CAHaNCheiJkh85iqOwgrxx_S7OMW4a82LGRgvNc2FSS_cTdAczA@mail.gmail.com>
URL: https://gitlist.dev/e/CAHaNCheiJkh85iqOwgrxx_S7OMW4a82LGRgvNc2FSS_cTdAczA%40mail.gmail.com
In-Reply-To: <CAGZ79kZ94Qh4CzCUWNYQQU5EB+Oky13gcp09tBKSYoCaFvqOuA@mail.gmail.com>

```
Appreciate it. Thanks a lot.
Regards,

Gyandeep Singh
Website: http://gyandeeps.com


On Mon, Jun 26, 2017 at 10:15 PM, Stefan Beller <sbeller@google.com> wrote:
> I miss-read your email.
>
> So you are not running Git, but only talk about the (Git-)bash that is
> conveniently bundled with Git for Windows?
> For that I recommend https://github.com/git-for-windows/git/issues/new
>
> Johannes Schindelin the GfW maintainer is cc'd here as well, but
> AFAICT he prefers Github issues.
>
> On Mon, Jun 26, 2017 at 8:08 PM, Gyandeep Singh <gyandeeps@gmail.com> wrote:
>> Not sure what you mean by output. But its just goes back to normal like  this
>>
>> Gyandeep@Gyandeep MINGW64 ~
>>
>> $
>>
>>
>>
>> It was working fine on first release of git 2.13. It broken with
>> releases after that.
>>
>> Will try with –no-pager flag and let you tomorrow.
>>
>>
>>
>> Thanks
>>
>> Gyandeep
>> Regards,
>>
>> Gyandeep Singh
>> Website: http://gyandeeps.com
>>
>>
>> On Mon, Jun 26, 2017 at 9:55 PM, Stefan Beller <sbeller@google.com> wrote:
>>> Which exact outputs of Git are invoked?
>>>
>>> Does it change when giving slightly different options e.g. --no-pager?

```

## Johannes Schindelin, 2017-06-28 14:40

Subject: Re: Bug: Cannot kill Nodejs process using ctrl + c
Message-ID: <alpine.DEB.2.21.1.1706281527120.84669@virtualbox>
URL: https://gitlist.dev/e/alpine.DEB.2.21.1.1706281527120.84669%40virtualbox
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

```

## Johannes Schindelin, 2017-06-29 20:12

Subject: Re: Bug: Cannot kill Nodejs process using ctrl + c
Message-ID: <alpine.DEB.2.21.1.1706292210230.84669@virtualbox>
URL: https://gitlist.dev/e/alpine.DEB.2.21.1.1706292210230.84669%40virtualbox
In-Reply-To: <alpine.DEB.2.21.1.1706281527120.84669@virtualbox>

```
Hi,

On Wed, 28 Jun 2017, Johannes Schindelin wrote:

> On Mon, 26 Jun 2017, Gyandeep Singh wrote:
> 
> [... a bug report ...]

This bug report was reposted as

	https://github.com/git-for-windows/git/issues/1219

In my opinion, it is too Windows-specific for the discussion to continue
anywhere but in that ticket.

Ciao,
Johannes

```
