Skip to content

Add Process kill and signal APIs - #99

Merged
floitsch merged 7 commits into
mainfrom
feature/process-kill
Aug 29, 2026
Merged

Add Process kill and signal APIs#99
floitsch merged 7 commits into
mainfrom
feature/process-kill

Conversation

@floitsch

@floitsch floitsch commented Aug 29, 2026

Copy link
Copy Markdown
Member

Summary

  • add immediate Process.kill with an optional hard flag
  • add explicit blocking Process.kill --wait with optional hard-after-ms escalation
  • treat hard-after-ms=0 as hard-only termination followed by waiting for exit
  • add Process.signal as the platform-specific escape hatch
  • preserve outer deadlines so an enclosing with-timeout can safely abort the blocking overload
  • document that Windows termination is always immediate because arbitrary child processes have no catchable SIGTERM equivalent

This is stacked on #98 because the blocking overload relies on cancellation-safe retryable Process.wait. Native signaling error propagation is in toitlang/toit#3197.

Behavior

  • process.kill sends SIGTERM on POSIX and terminates immediately on Windows, then returns
  • process.kill --hard sends SIGKILL on POSIX and terminates immediately on Windows, then returns
  • process.kill --wait sends the normal termination request and waits indefinitely on POSIX until voluntary exit
  • process.kill --wait --hard-after-ms=1000 waits up to one second for graceful exit, escalates, and then waits until exit
  • process.kill --wait --hard-after-ms=0 hard-terminates and waits until exit
  • process.signal value sends a platform-specific signal; Windows supports signal 9

Tests

  • toit analyze src/pipe.toit
  • toit analyze tests/process_kill_test.toit tests/pipe2_test.toit
  • toit run tests/process_kill_test.toit
  • toit run tests/pipe2_test.toit
  • both tests passed with the rebuilt SDK
  • coverage includes immediate soft and hard termination, blocking termination, invalid grace periods, explicit signals, ignored SIGTERM escalation, handled SIGTERM without escalation, and aborting the blocking overload through an outer timeout

@floitsch
floitsch force-pushed the feature/process-kill branch from b033d48 to 949becd Compare August 29, 2026 13:54
Base automatically changed from fix/cancel-safe-process-wait to main August 29, 2026 17:25
@floitsch
floitsch merged commit 8747d4d into main Aug 29, 2026
7 checks passed
@floitsch
floitsch deleted the feature/process-kill branch August 29, 2026 17:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant