threads / bug / 46264

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

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

## tl;dr

7 messages between Jun 26, 2017 and Jun 29, 2017.

replies: 6people: 3as markdown or json

Gyandeep Singh· Jun 26, 2017, 20:45 UTC · lore
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
Gyandeep Singh· Jun 27, 2017, 03:08 UTC · re: Stefan Beller · lore
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· Jun 27, 2017, 03:15 UTC · re: Gyandeep Singh · lore
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:
Show 28 quoted lines
> 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· Jun 27, 2017, 03:17 UTC · re: Stefan Beller · lore

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:
Show 38 quoted lines
> 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· Jun 28, 2017, 14:40 UTC · re: Gyandeep Singh · lore
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· Jun 29, 2017, 20:12 UTC · re: Johannes Schindelin · lore
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

← back to recent threads