PAM: failed fork() leads to kill(-1, SIGKILL), terminating the user session
A failed fork() during PAM authentication leaves childPid set to -1. Error handling then calls kill(-1, SIGKILL), which can terminate the compositor, terminals, and other processes the user can signal, ending the session and losing unsaved work.
Cause
Confirmed on master 11ca60b:
subprocess.cpplogs the fork failure and returns-1.conversation.cpponly treats0as failure, so it accepts-1as the child PID and arms a notifier on the default input fd,0(stdin).abort()andinternalError()checkchildPid != 0, then callkill(-1, SIGKILL)andwaitpid(-1). The latter can also reap an unrelated child.
With stdin set to /dev/null (as under DMS), this happens immediately after start(). With an open pipe, it happens on abort. Fork failure can occur when process/thread limits are reached or memory is exhausted. The failure path also leaks four pipe fds and three duplicated strings.
Verification
I reproduced this safely using an LD_PRELOAD shim that makes fork() fail with EAGAIN and logs non-positive-PID kill calls instead of executing them. It recorded kill(-1, SIGKILL) and waitpid(-1). Authentication with a successful fork does not trigger this.
Suggested fix
Clean up and return 0 on fork failure so start() reports InternalError, and require childPid > 0 in both cleanup handlers.
This code has been present since commit e89035b (2024-06-18). I found no existing report or fix in open or closed issues/PRs; #1256 does not touch this path.