2 Launch a process (given through argv) similar to how a shell would do it.
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.
18 # And put it in the foreground.
19 fd
= os
.open("/dev/tty", os
.O_RDONLY
)
20 os
.tcsetpgrp(fd
, os
.getpgid(0))
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
)