15.5 Signals
On a Unix system, a signal is a message to a process. Such signals are often used to terminate a process. However, you can also just send some information to the process, for example, that the window size has changed. Most signals you send to a Node.js process cause an event to which you can bind a callback function to respond to the signal. For example, if a user presses the shortcut (Ctrl)+(C), the SIGINT signal gets triggered. You can intercept this via process.on('SIGINT', () => {}) and act accordingly. When integrating it into your Math Trainer application, you have to keep in mind that the readline interface intercepts the signals, so you can’t respond to them directly. The solution to this problem is to register the event ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access