Description
Under certain circumstances if spawn() throws in Configuration.run, process resources will never be freed (zombies won't be reaped on Unix) if the call to spawn() throws an error after posix_spawn or fork/exec has successfully returned a pid.
This "resource leak" doesn't affect Windows because the only point at which spawnDirect/spawnAsUser can throw after a successful process creation explicitly releases the handles if closing file handles fails, but the process may still continue running.
On Unix (both Darwin and non-Darwin implementations are affected), failing to close file handles after a successful spawn, or failing to access the working directory, can trigger this bug. In this case we should probably SIGKILL the process and perform termination monitoring to wait for exit.
A good way to do this could be to remove Execution from SpawnResult and then change the return type of spawn to something like Result<(Execution, SpawnResult), (Execution?, Error)>
(where the Execution nullability indicates whether the failure occurred pre- or post- spawn of the actual process) while turning spawn into a non-throwing function.