Node.js process.kill() is not killing a child process on Windows OS

53 Views Asked by At

I want to kill a child process created using spawn in Node.js

Its working fine on Linux OS

var spawn = require('child_process').spawn;
var child = spawn('kate', {detached: true}); // to open Kate editor on linux
process.kill(child.pid);

On Window 11 its not working

var spawn = require('child_process').spawn;
var child = spawn('notepad', {detached: true}); // to open Notepad editor on Windows
process.kill(child.pid);

process.kill() is returning true but process still exists.

Why process.kill() is not working on Windows OS to kill a child process?

0

There are 0 best solutions below