Skip to content

Commit 533f3a8

Browse files
Copilotludfjig
andcommitted
Improve kill() documentation with clearer structure
Updated the documentation for InterruptHandle::kill() based on feedback to: - Use clearer language about canceling guest execution - Better explain the return value meaning - Separate platform-specific behavior into its own section - Remove technical details about signals in favor of user-focused description Co-authored-by: ludfjig <[email protected]>
1 parent 8b7a60c commit 533f3a8

File tree

1 file changed

+12
-13
lines changed
  • src/hyperlight_host/src/hypervisor

1 file changed

+12
-13
lines changed

src/hyperlight_host/src/hypervisor/mod.rs

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -206,22 +206,21 @@ pub(crate) trait InterruptHandleImpl: InterruptHandle {
206206

207207
/// A trait for handling interrupts to a sandbox's vcpu
208208
pub trait InterruptHandle: Send + Sync + Debug {
209-
/// Interrupt the corresponding sandbox from running.
209+
/// Cancel guest execution in the corresponding sandbox.
210210
///
211-
/// This method sets a cancellation flag that prevents or stops the execution of guest code.
211+
/// If a guest call is in progress, it will be cancelled and the guest function call
212+
/// will return an error. If called before a guest call is made, it has no effect on
213+
/// future guest calls.
212214
///
213-
/// # Return Value
215+
/// # Returns
216+
/// - `true` if a guest call was in progress and the vcpu was actively running.
217+
/// - `false` otherwise (no guest call in progress, or guest call in progress but vcpu
218+
/// not yet running). Any in-progress guest call will still be cancelled.
214219
///
215-
/// The return value indicates whether a signal was sent to interrupt a running vCPU:
216-
/// - On Linux: Returns `true` if a signal was sent to the vCPU thread, `false` if the vCPU was not running.
217-
/// - On Windows: Returns `true` if `WHvCancelRunVirtualProcessor` was called successfully, `false` otherwise.
218-
///
219-
/// **Important**: A return value of `false` does not mean the cancellation failed. The cancellation flag is
220-
/// always set, which will prevent or stop execution. A `false` return simply means no signal was sent because
221-
/// the vCPU was not actively running at that moment.
222-
///
223-
/// # Note
224-
/// This function will block for the duration of the time it takes for the vcpu thread to be interrupted.
220+
/// # Platform behavior
221+
/// - **Linux**: If the vcpu is running, this function will block for the duration of
222+
/// the time it takes for the vcpu thread to be interrupted.
223+
/// - **Windows**: This function returns immediately after requesting cancellation.
225224
fn kill(&self) -> bool;
226225

227226
/// Used by a debugger to interrupt the corresponding sandbox from running.

0 commit comments

Comments
 (0)