/** The detached runner (base64'd into the pod, run under `setsid`). Self-reports pgid; streams output to out/err. */ export declare function buildBgRunnerScript(dir: string): string; /** Short foreground launcher: writes cmd.sh + runner.sh, then `setsid`s the runner detached and returns immediately. */ export declare function buildBgLauncherScript(dir: string, cmdShB64: string, runnerShB64: string): string; /** Poll script: emit totals + liveness + exit, then the new bytes per stream (base64, bounded by `readCap`). */ export declare function buildBgPollScript(dir: string, stdoutCursor: number, stderrCursor: number, readCap: number): string; /** KillShell: graceful SIGTERM to the group, then a forced SIGKILL (idempotent — a dead group just errors out). * The `|| kill ` fallback covers an ADOPTED exec whose pgid prelude self-reported `$$` without a `setsid` * (whether the k8s-exec'd sh is a group leader is runtime-dependent); a launch-mode runner is always setsid'd, * so its group kill succeeds and the fallback never fires there. */ export declare function buildBgKillScript(dir: string): string; /** dispose: forced SIGKILL to the group + remove the job dir (no grace — teardown). Best-effort. * ⚠️ Deliberately NO pgid-wait (unlike {@link buildBgKillScript}, review #4): a create-then-abort adopt disposed * in the pre-mkdir window escapes THIS script — but every dispose path ends in pod deletion (task-end destroy; * suspendVM deletes the pod after the snapshot), so the escape is pod-lifetime-bounded, and a wait here would * add 2s × N shells to the suspend/teardown path for a sub-second window. Kill (the model-facing wall) waits. */ export declare function buildBgDisposeScript(dir: string): string; /** * [ref] detach: wrap a foreground exec so it is ADOPTABLE mid-flight, running the command as a real * process-group LEADER so an adopted shell's KillShell / BG hard wall reap the WHOLE subtree. * * 🔴 review MED (why `setsid`, not bare `$$`): the wrapper `sh` that `kubectl exec` starts has a RUNTIME-DEPENDENT * process group — under many container runtimes it is NOT its own group leader (its pgid is some ancestor's), so * writing `$$` as the pgid and later `kill -$$` targets a group that does not exist → the fallback `kill $$` reaps * only the wrapper, orphaning the command's children PAST the §3.6 hard wall (they keep streaming into the adopted * shell's buffer until the pod's `activeDeadlineSeconds`). `setsid` starts the command in a NEW session ⇒ a new * process group whose leader pid IS the backgrounded job pid, so `kill -` reaps the command and every * descendant. The command's stdout/stderr fds (the exec socket's channels) are INHERITED across setsid — only the * controlling terminal is dropped (there is none: kubectl-exec here is non-tty) — so output/exit still flow on the * SAME WebSocket, which IS the adopted shell's feed. `wait` propagates the real exit code. * * The command is base64'd into a pod-side `cmd.sh` (no quoting hazard, mirrors the launch path). The pgid is written * atomically (tmp+mv) AFTER the job forks, so a poll never reads a half-written id. Every step is best-effort: a pod * without `setsid` (rare on the kata base image) degrades to the `$$` path (the pre-fix behavior), and a read-only * /tmp degrades to a pgid-less adopt (kill no-ops; the disposable pod's teardown reaps) — never a broken exec. The * EXIT trap removes the dir when the command ends normally, so non-detached execs don't litter the pod. */ export declare function buildDetachCapableExec(dir: string, command: string): string; /** Parsed background poll response. `gone` = the job dir vanished (abnormal). Byte counts drive cursor/dropped accounting. */ export interface ParsedBgPoll { gone: boolean; outTotal: number; errTotal: number; exitCode?: number; alive: boolean; stdout: string; stdoutBytes: number; stderr: string; stderrBytes: number; } /** Parse {@link buildBgPollScript} stdout. Markers contain `_` (absent from the base64 alphabet) so they never collide. */ export declare function parseBgPollOutput(raw: string): ParsedBgPoll | undefined; //# sourceMappingURL=k8s-bg-scripts.d.ts.map