mscdex / node-ncurses

An ncurses binding for node.js
MIT License
386 stars 25 forks source link

Ctrl-C from any example supplied corrupts terminal #47

Open JavaScriptDude opened 10 years ago

JavaScriptDude commented 10 years ago

When I run any of the examples and exit one of them using ctrl-c, the terminal is all messed up. Extra padding in outputing, some cases my typing is not displayed.

It appears that node-ncurses is not gracefully returning the shell back to a pristine state on SIGINT kill signal.

Is this issue because the example apps are not handling the kill signal and not calling cleanup()? If that is the case, maybe it would be a good idea to add this code into the examples so to make it less troublesome for n00bs.

JavaScriptDude commented 10 years ago

I have confirmed that this issue can be resolved by adding the following code to the examples.

process.on('SIGTERM', function () { 
    console.log('Got SIGTERM, exiting...'); 
    nc.cleanup();
    win.close();
    process.exit(0); 
});

process.on('SIGINT', function () { 
    console.log('Got SIGINT, exiting...'); 
    nc.cleanup();
    win.close();
    process.exit(0); 
});

I would recommend that this code be added to the examples to assist others.