Skip to content

Commit 1764f1e

Browse files
author
wll8
committed
fix: ctrl+c does not end the child process
1 parent 7338a82 commit 1764f1e

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

lib/spawnify.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,15 @@ Spawnify.prototype._set = function set(type, command, options) {
158158
this._setListeners(child);
159159

160160
this.on('kill', (code) => {
161-
child.kill(code);
161+
// Can only end the first process
162+
// child.kill(code);
163+
164+
// Can end subprocess, but at the expense of `code`
165+
import('fkill').then(fkill => fkill.default(child.pid, {
166+
force: true,
167+
})).catch(err => {
168+
console.log(`Process has been terminated, or other errors.`)
169+
});
162170
});
163171

164172
this.on('write', (data) => {

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"node": ">=14"
2222
},
2323
"dependencies": {
24+
"fkill": "^8.0.1",
2425
"glob": "^7.1.0",
2526
"tildify": "^2.0.0",
2627
"try-catch": "^3.0.0",

0 commit comments

Comments
 (0)