diff --git a/madbg/tty_utils.py b/madbg/tty_utils.py index cd1423c..f804405 100644 --- a/madbg/tty_utils.py +++ b/madbg/tty_utils.py @@ -53,8 +53,12 @@ def detach_ctty(ctty_fd): fcntl.ioctl(ctty_fd, termios.TIOCNOTTY) -def attach_ctty(fd): - fcntl.ioctl(fd, termios.TIOCSCTTY, 1) +def attach_ctty(fd: int) -> bool: + try: + fcntl.ioctl(fd, termios.TIOCSCTTY, 1) + return True + except PermissionError: + return False def get_ctty_fd() -> Optional[int]: @@ -112,9 +116,9 @@ def set_tty_attrs(self, tc_attrs, when=termios.TCSANOW): tc_attrs[CC] = current_attrs[termios.CC] termios.tcsetattr(self.slave_fd, when, tc_attrs) - def make_ctty(self): + def make_ctty(self) -> bool: detach_current_ctty() - attach_ctty(self.slave_fd) + return attach_ctty(self.slave_fd) @classmethod @contextmanager diff --git a/setup.cfg b/setup.cfg index 9bc0b83..666c58d 100644 --- a/setup.cfg +++ b/setup.cfg @@ -9,7 +9,7 @@ install_requires = [metadata] name = madbg -version = 1.2.0 +version = 1.2.1 description = A fully-featured remote debugger for python author = Maor Kleinberger author_email = kmaork@gmail.com