Skip to content

Add OnStart and opt-in KillOnCancel - #88

Open
ShalokShalom wants to merge 1 commit into
CaptnCodr:mainfrom
ShalokShalom:pr/fli-kill-on-cancel
Open

ShalokShalom wants to merge 1 commit into
CaptnCodr:mainfrom
ShalokShalom:pr/fli-kill-on-cancel

Conversation

@ShalokShalom

Copy link
Copy Markdown

Summary

Adds two opt-in builder operations for both Shell and Exec contexts:

  • OnStart (int -> unit) reports the process id as soon as the process starts, so a supervisor can track it before the command finishes.
  • KillOnCancel true changes async cancellation from abandoning the child to killing the process tree and returning an Output with ExitCode = 124 and Error = "operation cancelled".

Default behaviour is unchanged. Without KillOnCancel, cancellation still throws as before.

Motivation

Command.executeAsync waits with WaitForExitAsync(cancellationToken), but on cancellation it did not kill the child. In a watchdog that is fatal: a cancelled sleep 30 survived and was reparented to init. A supervisor needs both the PID early and a way to make cancellation actually terminate the process tree.

Verification

  • dotnet test src/Fli.Tests/Fli.Tests.fsproj -c Release — 67 passed, 0 failed on net10.0.
  • New example test runs sleep 30 with a 1s budget, asserts exit code 124, matching PID, and that the child is gone.
  • Documentation and release notes updated; version bumped to 1.1002.0.0.

Stack

PR 1 of 3. The following PRs add property-based tests and toolchain updates on top of this change.

OnStart reports the process id as soon as a command starts, for supervisors that need the pid before completion. KillOnCancel makes async cancellation kill the child process tree and return exit 124 instead of orphaning it. Adds builder operations for both Shell and Exec contexts, tests and documentation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant