Skip to content

Commit 7e8837e

Browse files
committed
fix: after exit codeflare UI leaves dangling watcher processes
For some reason, a normal SIGTERM is not sufficing to clean up the watcher subprocesses we spawned.
1 parent a14f51c commit 7e8837e

File tree

1 file changed

+10
-4
lines changed
  • plugins/plugin-codeflare/src/tray/watchers/profile

1 file changed

+10
-4
lines changed

Diff for: plugins/plugin-codeflare/src/tray/watchers/profile/status.ts

+10-4
Original file line numberDiff line numberDiff line change
@@ -65,21 +65,27 @@ export default class ProfileStatusWatcher {
6565
const job = spawn(argv[0], argv.slice(1), { env, stdio: ["pipe", "pipe", "inherit"], detached: true })
6666

6767
// make sure to kill that watcher subprocess when we exit
68-
process.on("exit", () => {
68+
const onExit = () => {
6969
if (job.pid) {
7070
try {
71-
process.kill(-job.pid) // kill the process group e.g. for pipes
71+
Debug("codeflare")("killing process group " + -job.pid)
72+
process.kill(-job.pid, "SIGKILL") // kill the process group e.g. for pipes
7273
} catch (err) {
7374
Debug("codeflare")("error killing process group " + -job.pid, err)
7475
}
7576
}
7677

7778
try {
78-
job.kill()
79+
Debug("codeflare")("killing process " + job.pid)
80+
job.kill("SIGKILL")
7981
} catch (err) {
8082
Debug("codeflare")("error killing process " + job.pid, err)
8183
}
82-
})
84+
}
85+
86+
process.on("exit", onExit)
87+
process.on("SIGINT", onExit) // catch ctrl-c
88+
process.on("SIGTERM", onExit) // catch kill
8389

8490
job.on("error", () => {
8591
Debug("codeflare")("Watcher error", profile)

0 commit comments

Comments
 (0)