File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -52,20 +52,25 @@ export class UnixSignalService implements IUnixSignalService {
5252
5353 /**
5454 * Registers the given handler to execute for the given signal.
55- * @param signal The signal to register
55+ * @param signal The signal to register, for example SIGINT
5656 * @param handler The handler to use for the signal
5757 */
5858 public async registerSignalHandler (
5959 signal : NodeJS . Signals ,
6060 handler : ISignalHandler ,
6161 ) : Promise < void > {
6262 if ( ! this . _handlers . has ( signal ) ) {
63- this . _handlers . set ( signal , [ ( ) => {
64- // TODO I don't know why
65- console . error ( "process.exit" , signal , handler )
63+ // Ensure an erray with the default handler exists, to which more
64+ // handlers can be added
65+ const defaultHandler = ( ) => {
66+ console . error ( `Received signal ${ signal } , exiting` )
6667 process . exit ( )
67- } ] ) ;
68+ }
69+
70+ this . _handlers . set ( signal , [ defaultHandler ] ) ;
6871
72+ // Ensure all added handlers in the array are called, when the signal event
73+ // happens
6974 process . on ( signal , ( ) => this . handleSignal ( signal ) ) ;
7075 }
7176
You can’t perform that action at this time.
0 commit comments