vorpal icon indicating copy to clipboard operation
vorpal copied to clipboard

Added ability to disable/ignore Ctrl+C

Open HarelAshwal opened this issue 7 years ago • 3 comments

LK"I

Hi All,

Have you ever considered adding the ability to disable/ignore Ctrl+C ? I'm having application that the management console should always active. (and exiting options should be disabled)

Harel

HarelAshwal avatar Oct 31 '16 20:10 HarelAshwal

If you want to disable CTRL+C you can remove all keypress listeners on process.stdin :

const listeners = process.stdin.removeAllListeners('keypress');

// You can restore them later 
listeners.forEach(listener => process.stdin.addListener('keypress', listener));

See Node documentation for more information.

MatthieuLemoine avatar Dec 21 '16 00:12 MatthieuLemoine

In addition to @MatthieuLemoine 's observations, it's also important to note that a vorpal app is actually a collection of vorpal instances. You can use the show and hide methods to get rid of the delimiter, while still keeping the app itself running, all without using the interrupt of Ctrl-C.

LongLiveCHIEF avatar Dec 21 '16 15:12 LongLiveCHIEF

there's also this handler, but I am not sure if it will help

process.prependListener('SIGINT', function(){
   
});

it might be nice if vorpal would ignore SIGINT events with a boolean, something like this:

process.once('SIGINT', function(){
    if(Vorpal.ignoreSIGINTEvents){
       return;
    }
});

ORESoftware avatar Nov 06 '17 01:11 ORESoftware