Skip to content

Commit

Permalink
Forwards SIGTERM signals
Browse files Browse the repository at this point in the history
  • Loading branch information
arcanis committed Jul 5, 2021
1 parent d5b532c commit d64f979
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,8 @@ async function start(): Promise<void> {
// 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);
Expand Down
4 changes: 4 additions & 0 deletions src/util/child.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ let uid = 0;
export const exec = promisify(child.exec);

export function forkp(program: string, args: Array<string>, opts?: Object): Promise<number> {
const key = String(++uid);
return new Promise((resolve, reject) => {
const proc = child.fork(program, args, opts);
spawnedProcesses[key] = proc;

proc.on('error', error => {
reject(error);
Expand All @@ -30,8 +32,10 @@ export function forkp(program: string, args: Array<string>, opts?: Object): Prom
}

export function spawnp(program: string, args: Array<string>, opts?: Object): Promise<number> {
const key = String(++uid);
return new Promise((resolve, reject) => {
const proc = child.spawn(program, args, opts);
spawnedProcesses[key] = proc;

proc.on('error', error => {
reject(error);
Expand Down

0 comments on commit d64f979

Please sign in to comment.