Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lldb / test / API / driver / job_control / shell.py
blob678457e119c31411a792ba3fd9ab3e034413c71e
1 """
2 Launch a process (given through argv) similar to how a shell would do it.
3 """
5 import signal
6 import subprocess
7 import sys
8 import os
11 def preexec_fn():
12 # Block SIGTTOU generated by the tcsetpgrp call
13 orig_mask = signal.pthread_sigmask(signal.SIG_BLOCK, [signal.SIGTTOU])
15 # Put us in a new process group.
16 os.setpgid(0, 0)
18 # And put it in the foreground.
19 fd = os.open("/dev/tty", os.O_RDONLY)
20 os.tcsetpgrp(fd, os.getpgid(0))
21 os.close(fd)
23 signal.pthread_sigmask(signal.SIG_SETMASK, orig_mask)
26 if __name__ == "__main__":
27 child = subprocess.Popen(sys.argv[1:], preexec_fn=preexec_fn)
28 print("PID=%d" % child.pid)
30 _, status = os.waitpid(child.pid, os.WUNTRACED)
31 print("STATUS=%d" % status)
33 returncode = child.wait()
34 print("RETURNCODE=%d" % returncode)