Skip to content

Commit 47af964

Browse files
committed
fix: child process should be killed on exit
ref pnpm/pnpm#2033
1 parent c514fb0 commit 47af964

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,7 @@ function runCmd_ (cmd, pkg, env, wd, opts, stage, unsafe, uid, gid, cb_) {
312312
})
313313
process.once('SIGTERM', procKill)
314314
process.once('SIGINT', procInterupt)
315+
process.on('exit', procKill)
315316

316317
function procError (er) {
317318
if (er) {
@@ -335,7 +336,10 @@ function runCmd_ (cmd, pkg, env, wd, opts, stage, unsafe, uid, gid, cb_) {
335336
process.removeListener('SIGINT', procKill)
336337
return cb(er)
337338
}
339+
let called = false
338340
function procKill () {
341+
if (called) return
342+
called = true
339343
proc.kill()
340344
}
341345
function procInterupt () {

0 commit comments

Comments
 (0)