Question: I am using linux/cpython 3.3/bash. Here's my problem:

```
#!/usr/bin/env python3
from subprocess import Popen, PIPE, DEVNULL
import time

s = Popen('cat', stdin=PIPE, stdout=DEVNULL, stderr=DEVNULL)
s.stdin.write(b'helloworld')
s.stdin.close()
time.sleep(1000)     #doing stuff

```

This leaves `cat` as a zombie (and I'm busy "doing stuff" and can't `wait` on the child process). Is there a way in bash that I can wrap `cat` (e.g. through creating a grand-child) that would allow me to write to `cat`'s stdin, but have init take over as the parent? A python solution would work too, and I can also use nohup, disown etc.

Answer: 
Run the subprocess from another process whose only task is to wait on it.

```
pid = os.fork()
if pid == 0:
     s = Popen('cat', stdin=PIPE, stdout=DEVNULL, stderr=DEVNULL)
     s.stdin.write(b'helloworld')
     s.stdin.close()
     s.wait()
     sys.exit()
time.sleep(1000)

```
One workaround might be to "daemonize" your cat: fork, then quickly fork again and exit in the 2nd process, with the 1st one wait()ing for the 2nd. The 3rd process can then exec() `cat`, which will inherit its file descriptors from its parent. Thus you need to create a pipe first, then close stdin in the child and dup() it from the pipe.

I don't know how to do these things in python, but I'm fairly certain it should be possible.