From 84fab1056c8294b64fe8f9970b204ccb89bb6a36 Mon Sep 17 00:00:00 2001 From: Andrei Alecu Date: Fri, 8 Jan 2021 15:33:18 +0200 Subject: [PATCH 1/2] fix: SIGTERM not passed properly --- src/cli/index.js | 2 ++ src/util/child.js | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/src/cli/index.js b/src/cli/index.js index a7937a317a..fbf9f36d7c 100644 --- a/src/cli/index.js +++ b/src/cli/index.js @@ -634,6 +634,8 @@ async function start(): Promise { // innermost process, whose end will cause our own to exit. }); + handleSignals(); + try { if (/\.[cm]?js$/.test(yarnPath)) { exitCode = await spawnp(process.execPath, [yarnPath, ...argv], opts); diff --git a/src/util/child.js b/src/util/child.js index e83b819745..f178c62ab2 100644 --- a/src/util/child.js +++ b/src/util/child.js @@ -16,8 +16,10 @@ let uid = 0; export const exec = promisify(child.exec); export function forkp(program: string, args: Array, opts?: Object): Promise { + const key = opts.cwd || String(++uid); return new Promise((resolve, reject) => { const proc = child.fork(program, args, opts); + spawnedProcesses[key] = proc; proc.on('error', error => { reject(error); @@ -30,8 +32,10 @@ export function forkp(program: string, args: Array, opts?: Object): Prom } export function spawnp(program: string, args: Array, opts?: Object): Promise { + const key = opts.cwd || String(++uid); return new Promise((resolve, reject) => { const proc = child.spawn(program, args, opts); + spawnedProcesses[key] = proc; proc.on('error', error => { reject(error); From 12ec1d4aa10226868b89f73b5b87ba78d8f05f77 Mon Sep 17 00:00:00 2001 From: Andrei Alecu Date: Tue, 12 Jan 2021 15:00:44 +0200 Subject: [PATCH 2/2] use unique index as key `opts` is optional --- src/util/child.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/util/child.js b/src/util/child.js index f178c62ab2..a0538e8974 100644 --- a/src/util/child.js +++ b/src/util/child.js @@ -16,7 +16,7 @@ let uid = 0; export const exec = promisify(child.exec); export function forkp(program: string, args: Array, opts?: Object): Promise { - const key = opts.cwd || String(++uid); + const key = String(++uid); return new Promise((resolve, reject) => { const proc = child.fork(program, args, opts); spawnedProcesses[key] = proc; @@ -32,7 +32,7 @@ export function forkp(program: string, args: Array, opts?: Object): Prom } export function spawnp(program: string, args: Array, opts?: Object): Promise { - const key = opts.cwd || String(++uid); + const key = String(++uid); return new Promise((resolve, reject) => { const proc = child.spawn(program, args, opts); spawnedProcesses[key] = proc;