terminationHandler
TerminationHandler is a callback mechanism used in process management APIs to execute code when a launched external process ends. It is most commonly associated with the Foundation Process class on Apple platforms, where a terminationHandler property can be set to run a closure when the process terminates.
In practice, terminationHandler is a closure of the form (Process) -> Void and is assigned to a Process
Usage considerations include thread context and timing. The terminationHandler may execute on a background thread, and
Common use cases include asynchronous workflow orchestration, logging and auditing of external tasks, and coordinating multiple
Related concepts include the Process class, terminationStatus, and, in some cases, terminationReason (where available). Termination handling