Last active
May 28, 2019 11:18
-
-
Save chr5tphr/f516fe353151a8e7c3037c3f354e924f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from socket import socket, AF_UNIX | |
from pdb import Pdb | |
from os import unlink, getuid, getpid, chmod | |
from signal import signal, SIGUSR1 | |
def rtrace(signum, frame): | |
spath = '/tmp/{:d}.pdb.{:d}'.format(getuid(), getpid()) | |
with socket(AF_UNIX) as sock: | |
chmod(sock.fileno(), 0o700) | |
sock.bind(spath) | |
sock.listen(1) | |
conn, addr = sock.accept() | |
fd = conn.makefile('rw') | |
dbgr = Pdb(stdin=fd, stdout=fd) | |
dbgr.set_trace() | |
unlink(spath) | |
signal(SIGUSR1, rtrace) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment