Skip to content

Commit b353269

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

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-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) => {

0 commit comments

Comments
 (0)