Understanding Process Signals

A great feature of the process module is that it allows you to register listeners to handle signals that the operating system sends to a process. This is helpful when you need to perform certain actions such as cleanup before a process is stopped or terminated. Table 9.1 lists the process events for which you can add listeners.

Image

Table 9.1 Events that can be sent to Node.js processes

To register for a process signal, simply use the on(event, callback) method. For example, to register an event handler for the SIGBREAK event, you would use the following code:

process.on('SIGBREAK', function(){
  console.log("Got a SIGBREAK");
});

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.143.231.26