From 5c887a49dd8320472c700274a7cf471c2765c652 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Sat, 17 Jul 2021 15:57:12 +0200 Subject: [PATCH 1/2] Abort the watcher if stdin is closed to avoid zombie processes --- src/cli.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/cli.js b/src/cli.js index 5d33eafa495e..ca2698f2cdf2 100644 --- a/src/cli.js +++ b/src/cli.js @@ -784,6 +784,9 @@ async function build() { } if (shouldWatch) { + /* Abort the watcher if stdin is closed to avoid zombie processes */ + process.stdin.on('end', () => process.exit(0)); + process.stdin.resume(); startWatcher() } else { buildOnce() From f2a75bf5f1ead7ca3644f5b60fd727d1486b546b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Sun, 18 Jul 2021 10:07:50 +0200 Subject: [PATCH 2/2] Apply suggestions from code review --- src/cli.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cli.js b/src/cli.js index ca2698f2cdf2..9a79ce3f96e2 100644 --- a/src/cli.js +++ b/src/cli.js @@ -785,8 +785,8 @@ async function build() { if (shouldWatch) { /* Abort the watcher if stdin is closed to avoid zombie processes */ - process.stdin.on('end', () => process.exit(0)); - process.stdin.resume(); + process.stdin.on('end', () => process.exit(0)) + process.stdin.resume() startWatcher() } else { buildOnce()