Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

std.process.Child: detached child spawning #20876

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

antosikv
Copy link

Allow spawning a detached std.process.Child.

Tested manually on linux and windows, both seem to work and stay alive after closing the terminal/console. Simple test included but any suggestions for a better one definitely welcome (especially for windows).

Closes #19205

@antosikv antosikv changed the title Detached child std.process.Child: detached child spawning Jul 30, 2024
@antosikv
Copy link
Author

It might also be a good idea to add some sort of deinit function for when you have no intention of killing or waiting to properly dispose of any file descriptors/handles.

Also, any errors reported from the child that happen between fork and exec are currently only read after waiting or killing. Would it be a good idea to block in spawn until the child gets all the way to exec and return any errors up to that point immediately from spawn (it even has the correct signature for it so no breaking changes)? It would at least give you an opportunity to try again before you go do something else and in the case of detached processes it might be your only chance to know that the process didn't actually start doing anything.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

add cross-platform API to std.process.Child for spawning a detached process
2 participants