def spawn(self, command):
        """ Spawns a new process and adds it to the pool """

        # process_name
        # output
        # time before starting (wait for port?)
        # start_new_session=True : avoid sending parent signals to child

        env = dict(os.environ)
        env["MRQ_IS_SUBPROCESS"] = "1"
        env.update(self.extra_env or {})

        # Extract env variables from shell commands.
        parts = shlex.split(command)
        for p in list(parts):
            if "=" in p:
                env[p.split("=")[0]] = p[len(p.split("=")[0]) + 1:]
                parts.pop(0)
            else:
                break

        p = subprocess.Popen(parts, shell=False, close_fds=True, env=env, cwd=os.getcwd())

        self.processes.append({
            "subprocess": p,
            "pid": p.pid,
            "command": command,
            "psutil": psutil.Process(pid=p.pid)
        })
Spawns a new process and adds it to the pool