Changed spawn to fork, to work inside a fork.