There are three processes:
- A "control program", call it CP.
- CP launches a manager process, call it MP.
- MP launches a worker process, call it WP.
CP is the only program I can modify. All interaction with MP and WP is via stdin and stdout, and by operating system operations given the PID of MP and WP.
WP runs for a while and then signals that it is ready for the next stage.
I want CP take control of WP, detaching it from MP. CP will gain direct access to the stdin, stdout, stderr of WP. MP will then terminate, and WP will continue running under CP's control.
How can I do this on Linux, in Python?