diff --git a/src/process/capture/ProcessCaptureLifecycle.ts b/src/process/capture/ProcessCaptureLifecycle.ts index 7cc7703880..c6df725dd5 100644 --- a/src/process/capture/ProcessCaptureLifecycle.ts +++ b/src/process/capture/ProcessCaptureLifecycle.ts @@ -340,6 +340,10 @@ export const settleProcessCaptureJournal = async ( } }; +/** POSIX PTY capture limitation when same-group children remain running at target exit. */ +export const POSIX_PTY_SESSION_LEADER_SIGHUP_LIMITATION = + "The target runs as the capture PTY session leader; still-running children in its foreground process group receive terminal SIGHUP when it exits unless they leave the group or ignore SIGHUP."; + export const buildCaptureResult = ( options: CaptureResultOptions, ): PendingProcessCapture => { @@ -393,9 +397,7 @@ export const buildCaptureResult = ( : []), "Process trees are sampled and may omit short-lived descendants.", ...(options.manifest.platform !== "win32" - ? [ - "The target runs as the capture PTY session leader; still-running children in its foreground process group receive terminal SIGHUP when it exits unless they leave the group or ignore SIGHUP.", - ] + ? [POSIX_PTY_SESSION_LEADER_SIGHUP_LIMITATION] : []), ...(options.samplingPartial ? ["Process-tree sampling ended with an incomplete observation."] diff --git a/src/process/capture/ProcessCaptureObservation.test.ts b/src/process/capture/ProcessCaptureObservation.test.ts index d413dd00ac..ab54415eb6 100644 --- a/src/process/capture/ProcessCaptureObservation.test.ts +++ b/src/process/capture/ProcessCaptureObservation.test.ts @@ -4,7 +4,10 @@ import { ProcessCaptureSnapshotFailure, snapshotRoots, } from "./FilesystemSnapshot.js"; -import { buildCaptureResult } from "./ProcessCaptureLifecycle.js"; +import { + buildCaptureResult, + POSIX_PTY_SESSION_LEADER_SIGHUP_LIMITATION, +} from "./ProcessCaptureLifecycle.js"; import { readLinuxChildren } from "./LinuxProcessSampling.js"; import { TerminalRenderer } from "./TerminalRenderer.js"; import { processScenarioSchema } from "../../domain/process/processScenario.js"; @@ -364,14 +367,19 @@ it("records the PTY session-leader SIGHUP limitation on POSIX captures only", () eventJournal: [], }); + expect(POSIX_PTY_SESSION_LEADER_SIGHUP_LIMITATION).toMatch( + /PTY session leader/iu, + ); + expect(POSIX_PTY_SESSION_LEADER_SIGHUP_LIMITATION).toMatch(/SIGHUP/u); + expect(POSIX_PTY_SESSION_LEADER_SIGHUP_LIMITATION).toMatch(/group/iu); for (const posixPlatform of ["linux", "darwin"]) { expect(buildForPlatform(posixPlatform).limitations).toContain( - "The target runs as the capture PTY session leader; still-running children in its foreground process group receive terminal SIGHUP when it exits unless they leave the group or ignore SIGHUP.", + POSIX_PTY_SESSION_LEADER_SIGHUP_LIMITATION, ); } - expect( - buildForPlatform("win32").limitations.some((line) => - line.includes("SIGHUP"), - ), - ).toBe(false); + const winLimitations = buildForPlatform("win32").limitations; + expect(winLimitations).not.toContain( + POSIX_PTY_SESSION_LEADER_SIGHUP_LIMITATION, + ); + expect(winLimitations.some((line) => line.includes("SIGHUP"))).toBe(false); }); diff --git a/tests/boundary/process/ProcessEvidence.test.ts b/tests/boundary/process/ProcessEvidence.test.ts index 3db71a4bee..ea30471432 100644 --- a/tests/boundary/process/ProcessEvidence.test.ts +++ b/tests/boundary/process/ProcessEvidence.test.ts @@ -9,6 +9,7 @@ import { createRunManifest, observeLaunchedExecutable, observeSelectedExecutable, + POSIX_PTY_SESSION_LEADER_SIGHUP_LIMITATION, } from "../../../src/process/capture/ProcessCaptureLifecycle.js"; import { accountFullyObservedProcessCapture, @@ -230,6 +231,6 @@ it("projects the PTY session-leader SIGHUP limitation onto process capture Evide }); const evidence = createProcessCaptureEvidence(scenario, capture); expect(evidence.limitations).toContain( - "The target runs as the capture PTY session leader; still-running children in its foreground process group receive terminal SIGHUP when it exits unless they leave the group or ignore SIGHUP.", + POSIX_PTY_SESSION_LEADER_SIGHUP_LIMITATION, ); });