title: How can I execute a shell command in a child process in Python?
body: <p>I need to use the multiprocessing module (rather than subprocess, as I need to use pipes) to execute a shell command as a new child process. At the moment I'm using:</p>
  
  <pre><code>p = subprocess.Popen(subprocess_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=parent_env)
  </code></pre>
  
  <p>where <code>subprocess_command</code> is a shell command (it runs a Python script with arguments) and <code>parent_env</code> is the current environment with an environmental variable (LD_PRELOAD) set differently. What would be the equivalent using the multiprocessing module? The child process (Python script) needs to be able to pipe back to the parent.</p>