-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[feature] Write data to file on SIGINT unless specified #11
Conversation
@@ -147,7 +147,17 @@ asyncHook.enable(); | |||
// Print result | |||
// | |||
|
|||
process.on('exit', function () { | |||
if (process.argv.indexOf('--raw-sigint') === -1 || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perhaps call it --dprof-sigint
. The raw
part doesn't really make sense to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also shouldn't this be !== -1
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, the logic is correct -- I think it is better UX to have it as the default, as I suspect that is what most folks will expect.
That's also why I called it --raw-sigint
, as in, don't touch the default.
It could be something like --no-sigint-handler
or --no-dprof-sigint
.
The ENV variable exists for programs that may error on new flags.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should it not be !process.env.DPROF_RAW_SIGINT
then?
Thanks. You should document this. I guess it is not easy to test with the my odd testrunner, but at the very least you can have the script signal itself. // one of these
process.argv.push('--raw-sigint');
process.env.DPROF_RAW_SIGINT = '';
require('../../dprof.js');
setInterval(function () {}, 1000):
setTimeout(function () {
process.kill(process.pid, 'SIGINT');
}, 200); to make the test work:
|
7faab1a
to
0e9caa3
Compare
@AndreasMadsen updated |
@@ -147,7 +147,17 @@ asyncHook.enable(); | |||
// Print result | |||
// | |||
|
|||
process.on('exit', function () { | |||
if (process.argv.indexOf('--dprof-no-sigint') === -1 || | |||
process.env.DPROF_NO_SIGINT) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, the logic is correct -- I think it is better UX to have it as the default, as I suspect that is what most folks will expect.
Should it not be !process.env.DPROF_NO_SIGINT
then?
0e9caa3
to
1dcc7c6
Compare
@AndreasMadsen yup, good catch. Fixed I think. |
!process.env.DPROF_NO_SIGINT) { | ||
process.on('SIGINT', () => { | ||
writeDataFile(); | ||
process.exit(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This indicates a successful exit, however when I SIGINT a process I get the exit code 130
. According to http://unix.stackexchange.com/questions/99112/default-exit-code-when-process-is-terminated exit codes >= 128
indicates the process exited because of a signal.
I don't know if that is the case here, but surely the exit code should be >= 1
.
1dcc7c6
to
8fc3cb7
Compare
Hmmm, the test doesn't seem to fail with either the flag or variable uncommented, not really sure what's up. |
I've done a more thorough review ...
|
I've also updated the test runner to be more sensitive to some of these issues and more robust to other. There are some conflicts, I think you can just drop 8fc3cb7 and create a new one. |
Arrgh, right. I did some tracing of where the current node behavior comes from, and found this old issue. Apparently generically calling exit handles is a bad idea. I'm not actually sure how to exit without calling them... |
"some digging", wow that is a very old issue :) A crazy idea is to remove all |
8fc3cb7
to
6c8a7b2
Compare
Allows better debugging of applications that have handles that are preventing them from closing.
6c8a7b2
to
8b83818
Compare
Thought I fixed that. The I don't know why
Was, thinking about that too. If |
The Signal handling code is at https://github.com/nodejs/node/blob/master/lib/internal/process.js#L180-L219 tl;dr: they are shared. Maybe we should just go with this for now then? |
Allows better debugging of applications that have handles that are preventing them from closing. PR: #11
Thanks for looking that up.
Definitely. Landed in 2548239 ee3ee18 – Note I rename the test from |
Allows better debugging of applications that have handles that are preventing them from closing.