Fix Session Manager stdin EOF in group operator
The window A step A8 live run found that session-manager-plugin 1.2.896.0 reads EOF from DEVNULL, prints "Cannot perform start session: EOF", and exits zero without command output. Give session stdin the same raw PTY slave as stdout and stderr so it stays open and silent. Keep plain AWS invoke stdin on DEVNULL. Add child-terminal and fake-plugin regressions; both fail before the fix and pass afterward. All 210 roll, probe, and fault tests pass offline. No AWS calls were made.
2 files changed,
+36
−1
scripts/region-group-roll.py+3 −1scripts/region_group_roll_test.py+33 −0
CI passed — run details
diff --git a/scripts/region-group-roll.py b/scripts/region-group-roll.py| index 6373d01bf..5340e0503 100755 |
| --- a/scripts/region-group-roll.py |
| +++ b/scripts/region-group-roll.py |
| @@ -562,13 +562,15 @@ class AWS: |
| def session_output(command, env, timeout, on_session=None): |
| # The Session Manager plugin can lose buffered output without a terminal. |
| # A local PTY supplies one without an external unbuffer dependency. |
| + # Use it for stdin too: DEVNULL makes the plugin exit on EOF. The master |
| + # stays open without writes, so stdin remains open and silent. |
| master, slave = pty.openpty() |
| proc = None |
| body = bytearray() |
| sessions = set() |
| try: |
| tty.setraw(slave) |
| - proc = subprocess.Popen(command, stdin=subprocess.DEVNULL, stdout=slave, stderr=slave, |
| + proc = subprocess.Popen(command, stdin=slave, stdout=slave, stderr=slave, |
| env=env, start_new_session=True) |
| os.close(slave) |
| slave = None |
diff --git a/scripts/region_group_roll_test.py b/scripts/region_group_roll_test.py| index 9c4c64033..22fe8b03a 100644 |
| --- a/scripts/region_group_roll_test.py |
| +++ b/scripts/region_group_roll_test.py |
| @@ -1498,6 +1498,39 @@ class AdapterTests(unittest.TestCase): |
| self.assertIn("terminal=True", result) |
| self.assertIn("complete", result) |
| + def test_session_pty_stdin_is_terminal_without_eof(self): |
| + script = """import os |
| +print('terminal=' + str(os.isatty(0))) |
| +os.set_blocking(0, False) |
| +try: |
| + print('stdin=' + repr(os.read(0, 1))) |
| +except BlockingIOError: |
| + print('stdin=open and silent') |
| +""" |
| + result = roll.AWS.session_output([sys.executable, "-c", script], dict(os.environ), 5) |
| + self.assertIn("terminal=True", result) |
| + self.assertIn("stdin=open and silent", result) |
| + |
| + def test_session_pty_plugin_returns_frames_without_stdin_eof(self): |
| + plugin = Path(self.tmp.name) / "session-manager-plugin" |
| + plugin.write_text("#!" + sys.executable + "\n" + """import os |
| +os.set_blocking(0, False) |
| +try: |
| + eof = os.read(0, 1) == b'' |
| +except BlockingIOError: |
| + eof = False |
| +if eof: |
| + print('Cannot perform start session: EOF') |
| +else: |
| + print('nonce:BEGIN') |
| + print('{}') |
| + print('nonce:END:0') |
| +""") |
| + plugin.chmod(0o700) |
| + result = roll.AWS.session_output( |
| + [plugin.name], dict(os.environ, PATH=self.tmp.name), 5) |
| + self.assertEqual(result, "nonce:BEGIN\n{}\nnonce:END:0\n") |
| + |
| def test_session_pty_timeout(self): |
| with self.assertRaises(roll.Uncertain): |
| roll.AWS.session_output([sys.executable, "-c", "import time; time.sleep(10)"], dict(os.environ), 0.1) |