Refactor spawn.py. Move fork()/exec() logic to a different function.