Categories
JavaScript Answers

How to kill child process in Node.js?

Spread the love

To kill child process in Node.js, we call the kill method.

For instance, we write

const proc = require("child_process").spawn("mongod");
proc.kill("SIGINT");

to call spawn to run the mongod program.

Then we call kill with 'SIGINT' to kill the process.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *