Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider not changing ctty and emulating signals instead #13

Open
kmaork opened this issue Jul 7, 2020 · 2 comments · May be fixed by #44
Open

Consider not changing ctty and emulating signals instead #13

kmaork opened this issue Jul 7, 2020 · 2 comments · May be fixed by #44
Labels
enhancement New feature or request

Comments

@kmaork
Copy link
Owner

kmaork commented Jul 7, 2020

Changing the ctty is a cause to many complications and potential bugs in the code. For example:

  • Have to add special cases to allow client to force exit
  • Potential bugs while debugging a process with children (sighup delivered to children)
  • Changing ctty requires changing sid and pgid, or pid, which can interfere with some programs
  • Using setsid can cause zombie processes
  • There is apparently no easy way to restore the original ctty

The only (?) advantage of changing the ctty is to allow the tty driver to deliver signals to the process according to keys sent by the client. We could just emulate this behavior ourselves and save all the trouble of changing the actual ctty.

@kmaork kmaork added the question Further information is requested label Nov 11, 2021
@ascendant512
Copy link

I was going to open an bug, but then I saw this existing one (that at least seems to line up with the issue I encountered).
Python: 3.10.5
madbg: 1.2.0
I have an application running in uwsgi on another machine like so:

<uwsgi>
        <plugin>python310</plugin>
        <virtualenv>/home/me/venvs/serveframe</virtualenv>
        <wsgi-file>/home/me/www/u/serveframe.py</wsgi-file>
</uwsgi>

I added a breakpint like: madbg.set_trace(ip='my-ip', port=3513) and when I tried to connect to it from my PC with $ madbg connect my-ip 3513 it caused the application to crash. This is the end of the stack trace:

.../madbg/tty_utils.py", line 53, in attach_ctty
    fcntl.ioctl(fd, termios.TIOCSCTTY, 1)
PermissionError: [Errno 1] Operation not permitted

The line is

fcntl.ioctl(fd, termios.TIOCSCTTY, 1)

From ioctl_tty(2) I tried changing the third argument to 1 from 0, but it made no difference. I changed the line to just pass and was able to connect without an issue.

@kmaork
Copy link
Owner Author

kmaork commented Aug 17, 2022

Thank you! I am working on a new major version for madbg, and getting rid of this behavior will be one of the main updates in it. Until then, I fixed your specific issue and published a new minor version - try madbg==1.3.1 and see if it solved your case 😄

@kmaork kmaork added enhancement New feature or request and removed question Further information is requested labels Aug 17, 2022
@kmaork kmaork linked a pull request Oct 10, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants