Skip to content

Commit d12d3f0

Browse files
committed
fix(npm): kill child process when SIGTERM or SIGINT is received
1 parent 51f168f commit d12d3f0

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

npm/src/bin.mjs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,14 @@ if (!platformPackage) {
2828
process.exit(1)
2929
}
3030

31-
NodeChildProcess.spawn(selectBinaryPath(), process.argv.slice(2), { stdio: 'inherit' })
31+
const child = NodeChildProcess.spawn(
32+
selectBinaryPath(),
33+
process.argv.slice(2),
34+
{ stdio: 'inherit' }
35+
)
36+
37+
process.on('SIGINT', killChild)
38+
process.on('SIGTERM', killChild)
3239

3340
/**
3441
* Determines which tool wrapper is executing.
@@ -117,3 +124,10 @@ function selectBinaryPath() {
117124

118125
return NodePath.join(__dirname, '..', 'dist', binaryName)
119126
}
127+
128+
/**
129+
* Kills the child process.
130+
*/
131+
function killChild() {
132+
child.kill()
133+
}

0 commit comments

Comments
 (0)