From 7b0641cb55b486cb276aebe41b589471dd6affbd Mon Sep 17 00:00:00 2001 From: ehmicky Date: Sun, 28 Apr 2024 21:40:24 +0100 Subject: [PATCH] Document alternatives to process termination --- docs/termination.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/docs/termination.md b/docs/termination.md index 719b238bbb..4bad447776 100644 --- a/docs/termination.md +++ b/docs/termination.md @@ -6,6 +6,13 @@ # 🏁 Termination +## Alternatives + +Terminating a subprocess ends it abruptly. This prevents rolling back the subprocess' operations and leaves them incomplete. When possible, graceful exits should be preferred, such as: +- Letting the subprocess end on its own. +- [Performing cleanup](#sigterm) in termination [signal handlers](https://nodejs.org/api/process.html#process_signal_events). +- [Sending a message](ipc.md) to the subprocess so it aborts its operations and cleans up. + ## Canceling The [`cancelSignal`](api.md#optionscancelsignal) option can be used to cancel a subprocess. When [`abortController`](https://developer.mozilla.org/en-US/docs/Web/API/AbortController) is [aborted](https://developer.mozilla.org/en-US/docs/Web/API/AbortController/abort), a [`SIGTERM` signal](#default-signal) is sent to the subprocess.