/** * There is no systemd on this machine (macOS, a plain container, QTS), so there * is no unit and nothing to stop. Distinct from ACTIVE_STATE_UNKNOWN: this is a * definite answer, not a failed query. */ export declare const NO_SYSTEMD = "no-systemd"; /** * systemd is installed but `is-active` produced nothing we may act on — the bus * was unreachable, the output was empty, or it was a word we do not know. Never * a state systemd itself prints, so callers can test for it unambiguously. */ export declare const ACTIVE_STATE_UNKNOWN = "query-failed"; /** * Whether a live systemd manager is reachable on this Linux host. The presence * of the `systemctl` binary is not enough: minimal containers and non-systemd * distributions often ship it even though PID 1 is another init and there is no * manager bus to reload. A manager-level property query succeeds only when * systemctl can actually talk to systemd; an empty answer is not evidence of a * usable manager. Never throws so install can fail before making any changes. */ export declare function systemdManagerAvailable(): boolean; /** * The unit's active state, or one of the two sentinels above. Never throws, so * cmdStatus can render it on a machine without systemd. * * The exit code deliberately decides nothing: `is-active` exits non-zero for the * perfectly ordinary `inactive` and `failed` answers, printing the state word on * stdout either way. Only the word decides — and its absence is reported as such * rather than being folded into "inactive", because callers that delete a live * root agent's files on the strength of this answer (ctl/commands/uninstall.ts) * must be able to tell "it is stopped" from "we could not find out". */ export declare function systemctlActiveState(): string; export declare function systemctlIsEnabled(): boolean; /** * How long ONE systemctl call about a job scope may take before we stop waiting * on it. Both bounds exist because uninstall reaches these calls with the * service file, the ctl symlink, the binary and the state dir ALREADY deleted: * an unbounded wait there is a root CLI sitting mute in the middle of a * half-finished uninstall, with nothing on screen to say what it is waiting for. * * The number that forces the issue is systemd's DefaultTimeoutStopSec — 90 s on * a stock Ubuntu 24.04 / systemd 255. `systemctl stop` on a scope whose job * ignores SIGTERM blocks for the whole of it, PER UNIT, so a handful of stuck * jobs is minutes of silence. Against that, a scope whose job is cooperative * collapses in well under a second (measured: the unit is collected the instant * the process tree exits), so 15 s is many times the honest case and a sixth of * the pathological one — long enough that we never SIGKILL a job that was merely * slow to finish flushing, short enough that the operator gets an answer. * * Listing is a plain bus query that normally answers in milliseconds; 10 s is * there only for a wedged or heavily loaded manager. And SIGKILL delivery does * not wait for anything (measured at 0.01 s), so 5 s covers only the round trip. * * NOTE what a timeout does and does not do: it kills the systemctl CLIENT, not * the stop job systemd has already queued — the unit keeps going down on its own * schedule. So a timed-out stop is not a stopped unit, and callers must treat it * as a failure (ctl/commands/uninstall.ts does, and escalates). */ export declare const SCOPE_STOP_TIMEOUT_MS = 15000; export declare const SCOPE_LIST_TIMEOUT_MS = 10000; export declare const SCOPE_KILL_TIMEOUT_MS = 5000; /** * The transient job scopes still on this machine (job-scope.ts), or null when we * could not find out. * * The distinction matters to the caller and is why this does not simply return * `[]` on failure: an uninstall that cannot enumerate the scopes is about to * delete the workspaces and output.log files of jobs it cannot see, and must say * so rather than claim the machine is clean. A machine with no systemd has no * scopes and never asks — cmdUninstall gates on that before calling. * * There is no stale-unit duty here: a scope disappears the instant its process * tree ends, so this listing only ever contains LIVE jobs (measured on Ubuntu * 24.04 / systemd 255, along with the fact that `systemctl stop ` on a job * scope kills the whole tree and leaves the unit collected). * * The glob goes to `list-units`, which expands it itself; nothing built from * that output is ever passed back to systemctl without isJobScopeUnitName * agreeing it is one of ours. `--plain` gives bare unit names one per line; * without it every line is indented and carries the LOAD/ACTIVE/SUB/DESCRIPTION * columns, with the unit name still first — so the parse below survives a * systemd that ignores the flag, which is why it is written that way rather than * trusting the flag to have worked. */ export declare function listJobScopeUnits(): string[] | null; /** * Stop one unit BY NAME, gracefully (SIGTERM, then systemd's own escalation). * Separate from systemctlStop (which owns the service and takes no argument) * precisely so that no caller can hand a glob to a `stop`: the enumeration above * expands the pattern, this stops exactly what it found. Throws, so the caller * can account for a scope that would not go — INCLUDING one that merely ran past * SCOPE_STOP_TIMEOUT_MS, which is not a stopped unit either (see the constant). */ export declare function systemctlStopUnit(unit: string): void; /** * SIGKILL everything in one job scope's cgroup. The last resort of the uninstall * path, for a scope that would not stop within SCOPE_STOP_TIMEOUT_MS. * * `--kill-who=all` and not the default `main`: a scope's "main" process is the * job's `/bin/sh`, and killing only that would leave the real work — the trainer, * the compiler — running in a cgroup whose workspace and output.log the uninstall * is about to delete. The whole cgroup is what has to go. * * Guarded by the same isJobScopeUnitName check as the stop, for the same reason: * this is a root `systemctl kill` and the name it aims at came out of parsed text * output. And like the stop it throws — but note that a kill SUCCEEDING only * means the signal was sent; the caller (ctl/commands/uninstall.ts) re-lists the * scopes afterwards rather than believing it. */ export declare function systemctlKillUnit(unit: string): void; export declare function systemctlStart(): void; export declare function systemctlStop(): void; export declare function systemctlEnable(): void; export declare function systemctlDisable(): void; export declare function systemctlRestart(): void; export declare function daemonReload(): void; export declare function systemctlKill(): void;