-
-
Notifications
You must be signed in to change notification settings - Fork 69.4k
bug: parseLaunchctlPrint accepts PID 0 (inconsistent with systemd parser) #39188
Copy link
Copy link
Open
Description
Bug
parseLaunchctlPrint() in src/daemon/launchd.ts:131 only checks Number.isFinite(pid) before storing the PID, but the equivalent systemd parser at src/daemon/systemd.ts:122 correctly checks Number.isFinite(pid) && pid > 0.
When launchctl print reports pid = 0 (meaning no running process), the launchd parser stores pid: 0 in the result, which is semantically incorrect — PID 0 is the kernel scheduler, never a user-space service.
Inconsistency
// systemd.ts:122 — correct
if (Number.isFinite(pid) && pid > 0) {
info.mainPid = pid;
}
// launchd.ts:131 — missing pid > 0
if (Number.isFinite(pid)) {
info.pid = pid;
}Expected behavior
parseLaunchctlPrint should reject pid <= 0 the same way parseSystemdShowOutput does.
Impact
Low — the downstream readLaunchAgentRuntime at line 191 accidentally handles this because parsed.pid (0) is falsy in the ternary. But exposing pid: 0 to callers is semantically wrong and fragile.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Type
Fields
Give feedbackNo fields configured for issues without a type.