MCPcopy Create free account
hub / github.com/microsoft/debugpy / preexec_fn

Function preexec_fn

src/debugpy/launcher/debuggee.py:64–86  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

62 # GraalPy does not support running code between fork and exec
63
64 def preexec_fn():
65 try:
66 # Start the debuggee in a new process group, so that the launcher can
67 # kill the entire process tree later.
68 os.setpgrp()
69
70 # Make the new process group the foreground group in its session, so
71 # that it can interact with the terminal. The debuggee will receive
72 # SIGTTOU when tcsetpgrp() is called, and must ignore it.
73 old_handler = signal.signal(signal.SIGTTOU, signal.SIG_IGN)
74 try:
75 tty = os.open("/dev/tty", os.O_RDWR)
76 try:
77 os.tcsetpgrp(tty, os.getpgrp())
78 finally:
79 os.close(tty)
80 finally:
81 signal.signal(signal.SIGTTOU, old_handler)
82 except Exception:
83 # Not an error - /dev/tty doesn't work when there's no terminal.
84 log.swallow_exception(
85 "Failed to set up process group", level="info"
86 )
87
88 kwargs.update(preexec_fn=preexec_fn)
89

Callers

nothing calls this directly

Calls 1

closeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…