Skip to content

Zombies won't be reaped if spawn() throws in Configuration.run #105

@jakepetroules

Description

@jakepetroules

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.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions