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.

SIGINT (Ctrl+C) and SIGTERM are not handled

See original GitHub issue

When executing this file with c8 I get the coverage information.

function run() {
  if (1) {
    console.log(1);
  } else {
    console.log(2);
  }
}

run();

setTimeout(process.exit, 3000)

However if I kill the process using Ctrl+C before the timeout, I don’t get the coverage information for the code executed until that point.

Use case: I launch a service as a separate process and then launch integration tests (by sending requests to the service). Then I kill the service and check the coverage to make the tests pass. istanbul and nyc handle process kill correctly.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
aalexgabicommented, Sep 15, 2020

I created an issue for node: https://github.com/nodejs/node/issues/35212

Should c8 attach an event handler for SIGINT/SIGTERM etc. in the meantime ?

0reactions
aalexgabicommented, Jan 14, 2020

@bcoe @zbjornson Seems to be a node problem:

% NODE_V8_COVERAGE=/tmp/cov node /tmp/t.js
1
^C
% ls /tmp/cov
% 
Read more comments on GitHub >

github_iconTop Results From Across the Web

Is it possible to capture a Ctrl+C signal (SIGINT) and run a ...
Process.Signal(syscall.SIGTERM) or other signals are not supported on Windows. I handled this problem by creating a temp file as a signal.
Read more >
SIGINT (Ctrl-C) or SIGTERM (Ctrl-Break) as the *actually ...
Hey Brad,. Let me clarify the difference in behavior. When an agent exits, it can do so “gracefully” or not. A graceful leave...
Read more >
Handling Signals: Function signal()
The above program has two identical loops. However, before the first loop starts, signal SIGINT is ignored and, as a result, hitting Ctrl-C...
Read more >
Handling Interrupt Signals - ZeroMQ [Book] - O'Reilly
Realistic applications need to shut down cleanly when interrupted with Ctrl-C or another signal, such as SIGTERM . By default, these simply kill...
Read more >
SIGINT And Other Termination Signals in Linux - Baeldung
SIGINT is the signal sent when we press Ctrl+C. The default action is to terminate the process. However, some programs override this action...
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