From 9fe900aa017768234d5bfd163bee999e7359a669 Mon Sep 17 00:00:00 2001 From: Jon Parise Date: Fri, 12 Dec 2025 09:57:04 -0500 Subject: [PATCH] core: add Surface.stopProcess This keeps the IO backend interaction inside of the owning Surface code. --- src/Surface.zig | 8 ++++++++ src/apprt/embedded.zig | 4 +--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Surface.zig b/src/Surface.zig index 5d16f3326..3f582ea8b 100644 --- a/src/Surface.zig +++ b/src/Surface.zig @@ -851,6 +851,14 @@ pub fn close(self: *Surface) void { self.rt_surface.close(self.needsConfirmQuit()); } +/// Stop the child process by sending it the kill command (SIGHUP). +/// child_exited will be set once the child process has stopped. +pub fn stopProcess(self: *Surface) void { + switch (self.io.backend) { + .exec => |*exec| exec.subprocess.stop(), + } +} + /// Returns a mailbox that can be used to send messages to this surface. inline fn surfaceMailbox(self: *Surface) Mailbox { return .{ diff --git a/src/apprt/embedded.zig b/src/apprt/embedded.zig index cb0d2c0d4..c569f93e0 100644 --- a/src/apprt/embedded.zig +++ b/src/apprt/embedded.zig @@ -1602,9 +1602,7 @@ pub const CAPI = struct { /// Stops the child process by sending it the kill command (SIGHUP). export fn ghostty_surface_process_stop(surface: *Surface) void { - switch (surface.core_surface.io.backend) { - .exec => |*exec| exec.subprocess.stop(), - } + surface.core_surface.stopProcess(); } /// Returns true if the surface has a selection.