mirror of
https://github.com/markqvist/rnsh.git
synced 2025-02-25 09:21:15 -05:00
Fix issue with running rnsh without proper tty (like from launch)
This commit is contained in:
parent
14b718d88e
commit
2e61b70996
@ -184,7 +184,9 @@ class TTYRestorer(contextlib.AbstractContextManager):
|
|||||||
:param fd: file descriptor of tty
|
:param fd: file descriptor of tty
|
||||||
"""
|
"""
|
||||||
self._fd = fd
|
self._fd = fd
|
||||||
self._tattr = termios.tcgetattr(self._fd)
|
self._tattr = None
|
||||||
|
with contextlib.suppress(termios.error):
|
||||||
|
termios.tcgetattr(self._fd)
|
||||||
|
|
||||||
def raw(self):
|
def raw(self):
|
||||||
"""
|
"""
|
||||||
@ -210,12 +212,13 @@ class TTYRestorer(contextlib.AbstractContextManager):
|
|||||||
"""
|
"""
|
||||||
Restore termios settings to state captured in constructor.
|
Restore termios settings to state captured in constructor.
|
||||||
"""
|
"""
|
||||||
termios.tcsetattr(self._fd, termios.TCSADRAIN, self._tattr)
|
self.set_attr(self._tattr, termios.TCSADRAIN)
|
||||||
|
|
||||||
def __exit__(self, __exc_type: typing.Type[BaseException], __exc_value: BaseException,
|
def __exit__(self, __exc_type: typing.Type[BaseException], __exc_value: BaseException,
|
||||||
__traceback: types.TracebackType) -> bool:
|
__traceback: types.TracebackType) -> bool:
|
||||||
self.restore()
|
with contextlib.suppress(termios.error):
|
||||||
return False
|
self.restore()
|
||||||
|
return __exc_type is not None and issubclass(__exc_type, termios.error)
|
||||||
|
|
||||||
|
|
||||||
async def event_wait(evt: asyncio.Event, timeout: float) -> bool:
|
async def event_wait(evt: asyncio.Event, timeout: float) -> bool:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user