question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Generate report on Windows after proc.kill('SIGINT')`

See original GitHub issue

Hi,

Thank you for a great tool. I try to use node-clinic on my Windows 10 machine, but after I try to end my process using CTRL+C, nothing happens, the only process ends, without a report.

I clone node-clinic repo and make npm link to it, and change this line https://github.com/nearform/node-clinic-doctor/blob/master/index.js#L75 into
/*if (os.platform() !== 'win32') */ proc.kill('SIGINT'), to kill process on windows platform using SIGINT signal, and after i press CTRL+C in my command line, process end and report was analyzed.

I saw the comment in the code, but I don’t know why, but at the moment it works for me when I use this

 process.once('SIGINT', function () {  proc.kill('SIGINT') })
C:\Projekty\Learn\node-clinic>npm version
{ clinic: '1.0.3',
  npm: '6.1.0',
  ares: '1.10.1-DEV',
  cldr: '32.0',
  http_parser: '2.8.0',
  icu: '60.1',
  modules: '57',
  napi: '3',
  nghttp2: '1.32.0',
  node: '8.11.3',
  openssl: '1.0.2o',
  tz: '2017c',
  unicode: '10.0',
  uv: '1.19.1',
  v8: '6.2.414.54',
  zlib: '1.2.11' }

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
lukaszewczakcommented, Feb 21, 2020

Hi @DylanC , I tested with clinic doctor version v5.0.0, and it works! 😃. Thank you 😃

1reaction
lukaszewczakcommented, Aug 11, 2018

Hi @mafintosh ,

So I try to made a fork https://github.com/lukaszewczak/node-clinic-doctor, and put this change in the code (https://github.com/lukaszewczak/node-clinic-doctor/blob/master/index.js#L70)

process.once('SIGINT', function () {
    proc.kill('SIGINT')
 })

And to test it I change two scripts:

  1. cmd-collect-exit.test.js - I removed the code to skip test on Windows and I listen for child process exit event to test if it was killed by SIGINT signal
  2. cmd-collect-exit-sigint.script.js - I removed code `process.once(‘SIGINT’)), because child process cant’ capture this signal.

In general child process can’t capture the signal on Windows, it is just killed immediately by it, just like in the docs , this is why the previous writen test can not pass.

Windows does not support sending signals, but Node.js offers some emulation with process.kill(), 
and subprocess.kill(). Sending signal 0 can be used to test for the existence of a process. 
Sending SIGINT, SIGTERM, and SIGKILL cause the unconditional termination of the target process.

But 'SIGINT' from the terminal is supported on all platforms, which is the case in [node-clinic-doctor] (https://github.com/lukaszewczak/node-clinic-doctor/blob/master/index.js#L70) where the code is listening for SIGINT signal on the main process, not a child process.

I hope that my attempt to explain this behavior is quite understandable.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Go Graceful SIGINT killing - enzircle
In this problem, you are given a process that runs indefinitely and blocks the program. The only way to stop the program is...
Read more >
What is the Windows equivalent of process.on('SIGINT') in ...
This problem randomly occured to me today and I think it has something to do with the readline module itself. I couldn't do...
Read more >
Node.js process.kill() Method - GeeksforGeeks
'SIGHUP' is generated when the console window is closed. Return value : The process.kill() method will throw an error if the target pid...
Read more >
Process | Node.js v19.3.0 Documentation
'SIGHUP' is generated on Windows when the console window is closed, and on other platforms under various similar conditions. See signal(7) . It...
Read more >
kill-with-style - npm
When using on Windows make sure to make .timeout and .checkInterval larger, especially when there is need to kill multiple children.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found