title: os.chdir() doesn't work with mpi4py spawning
body: <p>I have a small test code that acts as a task farm. The idea is that a list of tasks will be sent to a group of processes spawned by mpi4py, which will in turn change to a run directory and spawn an mpi-executable in that directory before returning, and retrieving a new task. </p>
  
  <p>The problem is that the execution of mpi-executable seems to happen in the top level directory where the original program has been run. </p>
  
  <p>The master code is executed in /top/level/folder/</p>
  
  <p>and contains a list of tasks, e.g: [0,1,2,3,4,5,6,7,8,9,10]. The slaves each receive a task and change to a directory of the same name, before executing the mpi-executable, and then changing back.</p>
  
  <p>The master code:</p>
  
  <pre><code>#!/usr/bin/env python
  from mpi4py import MPI
  import numpy as np
  import sys
  import os
  import time
  
  
  comm = MPI.COMM_WORLD
  rank = MPI.COMM_WORLD.Get_rank()
  
  processes=4
  
  tasks=([StopIteration] * (processes))+[0,1,2,3,4,5,6,7,8,9,10]
  
  new_comm=comm.Spawn("/path/to/slave/slave.py",
                    args=[],maxprocs=processes)
  
  status=MPI.Status()
  
  while tasks:
      new_comm.recv(source=MPI.ANY_SOURCE, status=status)
      data=tasks.pop()
      print("on master received source: ",status.Get_source())
      print("On master sending: ",data," to:",status.Get_source())
      new_comm.send(obj=data,dest=status.Get_source())
      print("On master sent: ",data," to:",status.Get_source())
  
  
  print("Finished All",rank)
  new_comm.Barrier()
  print("after barrier",rank)
  print("rank", rank,"task",tasks)
  new_comm.Disconnect()
  </code></pre>
  
  <p>and the slave.py code:</p>
  
  <pre><code>#!/usr/bin/env python
  from mpi4py import MPI
  import numpy as np
  import sys
  import os
  import time
  
  comm = MPI.Comm.Get_parent()
  rank = comm.Get_rank()
  cwd=os.getcwd()
  
  print("slave", rank," entering loop")
  for task in iter(lambda: comm.sendrecv(dest=0), StopIteration):
      print("slave ", rank," recvd data", task)
      print("slave ", rank," going to sleep")
      directory=os.path.join(cwd,str(task))
      os.chdir(directory)
      new_comm=MPI.COMM_SELF.Spawn("/path/to/some/mpi-executable",
                    args=[],maxprocs=4)
      os.chdir(cwd)
      new_comm.Barrier()
      new_comm.Free()
  
  
  comm.Barrier()
  comm.Disconnect()
  </code></pre>
  
  <p>But each instance of the  mpi-executable is trying to launch in /top/level/folder/</p>
  
  <p>Any ideas as to why this behaviour is happening would be appreciated!</p>