From 5e788f0da48a13dae08b09ca8156a92f0884795d Mon Sep 17 00:00:00 2001 From: Aya Morisawa Date: Sat, 14 Jul 2018 00:39:39 +0900 Subject: [PATCH] Kill child process on exit --- src/daemons/notes-stats.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/daemons/notes-stats.ts b/src/daemons/notes-stats.ts index 021e6d64a..54ce746de 100644 --- a/src/daemons/notes-stats.ts +++ b/src/daemons/notes-stats.ts @@ -3,7 +3,7 @@ import Xev from 'xev'; const ev = new Xev(); -export default function() { +export default function () { const log: any[] = []; const p = childProcess.fork(__dirname + '/notes-stats-child.js'); @@ -17,4 +17,9 @@ export default function() { ev.on('requestNotesStatsLog', id => { ev.emit('notesStatsLog:' + id, log); }); + + process.on('exit', code => { + process.kill(p.pid); + }); + }