Node: Process.on('SIGINT') not fired in debugger

Created on 4 Jul 2016  路  8Comments  路  Source: nodejs/node

  • Version: 6.2.1
  • Platform: Darwin MacBook-Pro-di-Massimiliano.local 15.5.0 Darwin Kernel Version 15.5.0: Tue Apr 19 18:36:36 PDT 2016; root:xnu-3248.50.21~8/RELEASE_X86_64 x86_64
  • Subsystem:

Hi,
is there a way to get the event 'SIGINT' fired on _ctrl-c_ pressed in debug mode?
It seem that the event is correctly fired without debug, but not in debug mode.

thanks in advance

debugger question

All 8 comments

Can you clarify what you mean by 'debug mode' and post steps to reproduce?

Hi @bnoordhuis
I have this code in my index.js:

 process.on('SIGINT', function (){
     console.log('Hello');
 });

If I run my app normally with

 node index.js

and then close it with _CTRL+C_, the 'Hello' message pops out as expected.

Instead, if I run my app in debug mode with

 node debug index.js

and then close it with _CTRL+C_, no message is shown!

Okay, I believe I understand what you mean. It's because the ^C is intercepted by the debugger, to break out of loops and such.

I understand. Unfortunately we have some important database consistency check attached to this event, is there a way to achieve the same result while using the debugger? Thanks in advance!

You can kill -INT <pid> from another terminal. Make sure you send it to the pid of the debuggee (the child process started by the debugger), not the debugger itself.

Thank you for this workaround! Sadly this can't be considered a real solution, any other idea?

You could attach a SIGTERM listener, that's the signal that the debugger sends when it terminates the debuggee.

I'll go ahead and close the issue.

How to solve this problem?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

vsemozhetbyt picture vsemozhetbyt  路  3Comments

cong88 picture cong88  路  3Comments

srl295 picture srl295  路  3Comments

dfahlander picture dfahlander  路  3Comments

danielstaleiny picture danielstaleiny  路  3Comments