Summary
UnixLocalSandboxSession PTY children appear to inherit the parent process SIGINT disposition. If the parent is temporarily ignoring SIGINT, writing \x03 to a TTY-backed subprocess does not interrupt the child as expected.
Reproduction
The existing PTY interrupt behavior can fail with a long-running TTY process such as sleep 30 when the parent process is ignoring SIGINT.
A minimal repro shape is:
- Set the parent process handler for
SIGINT to SIG_IGN
- Start a PTY-backed subprocess via
UnixLocalSandboxSession.pty_exec_start(..., tty=True)
- Write
\x03 with pty_write_stdin
- Observe that the subprocess remains alive instead of exiting with signal
SIGINT
Expected behavior
PTY-backed children should treat Ctrl-C as an interrupt regardless of whether the parent process is temporarily ignoring SIGINT.
Actual behavior
The child can inherit the ignored SIGINT disposition, so terminal-generated Ctrl-C is ignored and the subprocess remains running.
Root cause hypothesis
In the UnixLocal PTY path, the child preexec_fn creates a new session and sets the controlling terminal, but it does not restore SIGINT to SIG_DFL before exec. That makes PTY behavior depend on the parent's current signal disposition.
Proposed fix
Reset SIGINT to SIG_DFL in the PTY child preexec_fn before exec, and add a regression test that temporarily sets the parent handler to SIG_IGN and verifies that \x03 still interrupts the child.
Summary
UnixLocalSandboxSessionPTY children appear to inherit the parent processSIGINTdisposition. If the parent is temporarily ignoringSIGINT, writing\x03to a TTY-backed subprocess does not interrupt the child as expected.Reproduction
The existing PTY interrupt behavior can fail with a long-running TTY process such as
sleep 30when the parent process is ignoringSIGINT.A minimal repro shape is:
SIGINTtoSIG_IGNUnixLocalSandboxSession.pty_exec_start(..., tty=True)\x03withpty_write_stdinSIGINTExpected behavior
PTY-backed children should treat Ctrl-C as an interrupt regardless of whether the parent process is temporarily ignoring
SIGINT.Actual behavior
The child can inherit the ignored
SIGINTdisposition, so terminal-generated Ctrl-C is ignored and the subprocess remains running.Root cause hypothesis
In the UnixLocal PTY path, the child
preexec_fncreates a new session and sets the controlling terminal, but it does not restoreSIGINTtoSIG_DFLbeforeexec. That makes PTY behavior depend on the parent's current signal disposition.Proposed fix
Reset
SIGINTtoSIG_DFLin the PTY childpreexec_fnbeforeexec, and add a regression test that temporarily sets the parent handler toSIG_IGNand verifies that\x03still interrupts the child.