From ad3403adb72e3457eb76d6b3fc91cf8df3d738ae Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 29 Sep 2026 09:51:11 -0300 Subject: A shell that cannot start fails Tty and pty/ctl exec with why, before either answers A shell whose exec failed (a script's missing interpreter) was reported started: Tty and pty/ctl exec succeeded, then the pane died. The child now reports a failed chdir or exec through a close-on-exec pipe the parent reads before acknowledging the shell; the host's spawn fails with the reason (`shell not found`, ENOENT), which fails the waiting write. A Tty whose first shell never ran leaves no pane; a terminal restarted by pty/ctl exec keeps its pane. Co-Authored-By: Claude Opus 5.5 --- test/fs.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'test/fs.py') diff --git a/test/fs.py b/test/fs.py index 3c10c53b..20a9bbff 100644 --- a/test/fs.py +++ b/test/fs.py @@ -515,6 +515,28 @@ def new_terminals_named_once(binary): for serial in made: assert f'\nrename {serial} ' not in '\n' + log, (serial, log) assert f'\nnew {serial} {root}' in '\n' + log, (serial, log) + # A shell that cannot start (its interpreter is not there): Tty + # fails the write with why and leaves no pane; pty/ctl exec + # fails with why and keeps its terminal. + bad = root / 'badsh' + bad.write_bytes(b'#!/nonexistent/interp\n') + bad.chmod(0o755) + panes = client.read('/index') + try: + client.write('/pane/1/ctl', f'Tty {bad}\n'.encode()) + raise AssertionError('Tty of a shell that cannot start was taken') + except OSError as refused: + assert 'shell' in str(refused), refused + time.sleep(.3) + assert client.read('/index').count(b'\n') == panes.count(b'\n'), client.read('/index') + client.write('/ctl', f'Shell {bad}\n'.encode()) + try: + client.write(f'/pane/{made[0]}/pty/ctl', b'exec\n') + raise AssertionError('pty/ctl exec of a shell that cannot start was taken') + except OSError as refused: + assert 'shell' in str(refused), refused + client.write('/ctl', b'Shell\n') + assert str(made[0]).encode() in b' '.join(r.split()[0] for r in client.read('/index').splitlines()) def workflow_canary(binary): -- cgit v1.3