()
| 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 |
nothing calls this directly
no test coverage detected
searching dependent graphs…