Skip to content
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

Add hint on infinite loops. #11

Closed
wants to merge 1 commit into from
Closed

Add hint on infinite loops. #11

wants to merge 1 commit into from

Conversation

mk-pmb
Copy link

@mk-pmb mk-pmb commented Sep 12, 2016

No description provided.

@myndzi
Copy link
Owner

myndzi commented Sep 12, 2016

When binding SIGINT, Node's ability to interrupt infinite loops goes away. I've published a new version that should take care of this by means of a watchdog process. You can use Ctrl+C twice to exit an infinitely looping process, but you won't be able to gather any information from it since it is forcefully killed.

@myndzi myndzi closed this Sep 12, 2016
@mk-pmb
Copy link
Author

mk-pmb commented Oct 22, 2016

When binding SIGINT, Node's ability to interrupt infinite loops goes away.

I hope that¹ can be improved for .once() handlers. -> node issue #9050

Edit: ¹ "that" = node's inability to interrupt loops when listening to (one) SIGINT. Relevant part of the other thread is my 2nd post ("Now for my real reason I'm here." …) and potential follow-up. I added the anchor to the link.

@myndzi
Copy link
Owner

myndzi commented Oct 22, 2016

Please note that wtfnode is a debugging tool, it's not meant to be used all the time, especially not in production. The fact that a program couldn't be ended in an infinite loop while running under wtfnode was a definite problem, but trying to implement/simulate some robust generic wrapping behavior is a different thing altogether. The purpose of the fix to this issue was to enable the user to terminate a script, not to provide a generic solution to the problem you linked.

The patch I made here doesn't actually execute the code in your script's SIGINT handler, because v8 can't do that. If it's in an infinite synchronous loop, no other code can run -- whether it's a recurrent .on handler or a one-off .once handler. wtfnode isn't fixing this problem, it's only dealing with the consequences.

I suspect that, to get the behavior you want, you'll need your own wrapper, so the process tree would be like:

wtfnode

  • your wrapper (with the once handler?)
    -- your actual script

It might be possible to provide some sort of api to let you register sigint (or, in general, signal handlers) with wtfnode to execute on your behalf, but I think that functionality is probably out of scope for wtfnode.

What would you like to see happen?

@myndzi
Copy link
Owner

myndzi commented Oct 22, 2016

P.S. I wouldn't be averse to maybe publishing some kind of generic signal handler wrapper thing that wtfnode could depend on, but I'm not sure it's worth it :) It's probably better to write node programs like node programs and not C programs...

@mk-pmb
Copy link
Author

mk-pmb commented Oct 23, 2016

Sorry for the confusion. I did not mean to request any change in wtfnode. In the other thread, after giving advice about the program structure, I questioned a node UX problem related to the SIGINT blocking, and meant to notify the subscribers of this issue because I thought they might be interested whether the SIGINT handling changes.

@myndzi
Copy link
Owner

myndzi commented Oct 23, 2016

Ah, I see! Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants