Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@rushstack/node-core-library",
"comment": "Handle SIGHUP in `SubprocessTerminator` the same way as SIGINT and SIGTERM, so detached child processes are cleaned up when the terminal is closed.",
"type": "patch"
}
],
"packageName": "@rushstack/node-core-library"
}
4 changes: 3 additions & 1 deletion libraries/node-core-library/src/SubprocessTerminator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const _isWindows: boolean = process.platform === 'win32';
* that the child gets terminated when the current process terminates.
*
* @remarks
* This works by hooking the current process's events for SIGTERM/SIGINT/exit, and ensuring the
* This works by hooking the current process's events for SIGTERM/SIGINT/SIGHUP/exit, and ensuring the
* child process gets terminated in those cases.
*
* SubprocessTerminator doesn't do anything on Windows, since by default Windows automatically
Expand Down Expand Up @@ -166,6 +166,7 @@ function _ensureInitialized(): void {

process.prependListener('SIGTERM', _onTerminateSignal);
process.prependListener('SIGINT', _onTerminateSignal);
process.prependListener('SIGHUP', _onTerminateSignal);

process.prependListener('exit', _onExit);
}
Expand All @@ -178,6 +179,7 @@ function _cleanupChildProcesses(): void {

process.removeListener('SIGTERM', _onTerminateSignal);
process.removeListener('SIGINT', _onTerminateSignal);
process.removeListener('SIGHUP', _onTerminateSignal);

const trackedSubprocesses: ITrackedSubprocess[] = Array.from(_subprocessesByPid.values());

Expand Down