Skip to content

Commit

Permalink
Merge pull request #39 from kmaork/bugfix/continue_when_cant_attach_t…
Browse files Browse the repository at this point in the history
…o_tty

Continue when can't attach to tty
  • Loading branch information
kmaork authored Aug 17, 2022
2 parents dee3137 + 2c15073 commit f5d821d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
12 changes: 8 additions & 4 deletions madbg/tty_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]:
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f5d821d

Please sign in to comment.