revert: remove SIGWINCH signal that caused connection loops
Sending SIGWINCH to the docker exec process was crashing/killing it, which closed the PTY and caused WebSocket 1006 abnormal closure loops. Reverting to the original TIOCSWINSZ-only approach.
This commit is contained in:
@@ -5,7 +5,6 @@ import logging
|
|||||||
import os
|
import os
|
||||||
import pty
|
import pty
|
||||||
import select
|
import select
|
||||||
import signal
|
|
||||||
import struct
|
import struct
|
||||||
import fcntl
|
import fcntl
|
||||||
import time
|
import time
|
||||||
@@ -84,7 +83,7 @@ class TerminalSession:
|
|||||||
self.last_activity = time.time()
|
self.last_activity = time.time()
|
||||||
|
|
||||||
def _set_terminal_size(self, cols: int, rows: int) -> None:
|
def _set_terminal_size(self, cols: int, rows: int) -> None:
|
||||||
"""Set the terminal size using TIOCSWINSZ and signal docker exec."""
|
"""Set the terminal size using TIOCSWINSZ."""
|
||||||
if self._master_fd is None:
|
if self._master_fd is None:
|
||||||
logger.warning("Cannot resize: master_fd is None (session not started)")
|
logger.warning("Cannot resize: master_fd is None (session not started)")
|
||||||
return
|
return
|
||||||
@@ -94,15 +93,6 @@ class TerminalSession:
|
|||||||
try:
|
try:
|
||||||
fcntl.ioctl(self._master_fd, TIOCSWINSZ, size)
|
fcntl.ioctl(self._master_fd, TIOCSWINSZ, size)
|
||||||
logger.info(f"Resized PTY to {cols}x{rows} (fd={self._master_fd})")
|
logger.info(f"Resized PTY to {cols}x{rows} (fd={self._master_fd})")
|
||||||
|
|
||||||
# Send SIGWINCH to docker exec process so it re-reads terminal
|
|
||||||
# size and propagates it to the container's PTY
|
|
||||||
if self.process and self.process.pid:
|
|
||||||
try:
|
|
||||||
os.kill(self.process.pid, signal.SIGWINCH)
|
|
||||||
logger.info(f"Sent SIGWINCH to docker exec pid={self.process.pid}")
|
|
||||||
except (OSError, ProcessLookupError) as e:
|
|
||||||
logger.warning(f"Failed to send SIGWINCH: {e}")
|
|
||||||
except (OSError, IOError) as e:
|
except (OSError, IOError) as e:
|
||||||
logger.error(f"Failed to resize PTY: {e}")
|
logger.error(f"Failed to resize PTY: {e}")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user