Skip to content

Instantly share code, notes, and snippets.

@chr5tphr

chr5tphr/usock_pdb.py

Last active May 28, 2019
Embed
What would you like to do?
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
You can’t perform that action at this time.