jtlapp / node-cleanup

installs custom cleanup handlers that run on exiting node
MIT License
164 stars 10 forks source link

Doesn't seem to work when output is piped #10

Open dandv opened 7 years ago

dandv commented 7 years ago

If I run my script (on Ubuntu) as node script.js 2>&1 | tee script.log and press ^C, nothing is printed or logged to the file. Without the piping, I do see the croak being logged.

const nodeCleanup = require('node-cleanup');
setTimeout(function () {}, 10000);
nodeCleanup(function (exitCode, signal) {
  // release resources here before node exits
  console.log('croak');
});
Akamaozu commented 5 years ago

I'm a Windows user so I'm only guessing here, but won't ctrl+c interrupt the entire pipeline, not just the current step?