Laode Muhammad Al Fatih
Laode Muhammad Al Fatih

Reputation: 4610

Does the child process in Node JS need to be killed manually?

I have a child process.

The Questions is:

Example

import { spawn } from 'child_process'

const backTaskProcess = spawn(process.execPath, ['back-task.js'], {
  cwd: process.cwd(),
})

// Do i need to disabled it manually?
process.on('SIGQUIT', () => {
  backTaskProcess.kill('SIGQUIT')
})

Upvotes: 1

Views: 581

Answers (1)

Zac Anger
Zac Anger

Reputation: 7767

No, no, and yes. You don't need to kill it manually, unless you use detached: true in the options. There are exceptions when using fork(), but that doesn't apply to your code.

Upvotes: 3

Related Questions