From 2e9e300d0c1b5297bf5a5066cd03310f3ff41fa2 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); + }); + }