-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
process: kill child on error while spawning #6803
Open
Maki325
wants to merge
3
commits into
tokio-rs:master
Choose a base branch
from
Maki325:fix/kill-process-on-error
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We already define
ChildDropGuard
intokio/src/process/mod.rs
. Can we:unix
andwindows
modules?StdChild
is wrapped so we don't end up double wrapping?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can maybe combine
ChildDropGuard
fromtokio/src/process/unix/mod.rs
andDroppableChild
fromtokio/src/process/windows.rs
, and have it intokio/src/process/mod.rs
, but we cant useChildDropGuard
fromtokio/src/process/mod.rs
. The reason being that we want the ability to take the child out from the Wapper struct, andChildDropGuard
fromtokio/src/process/mod.rs
doesn't allow that. The reason being that implementingDrop
doesn't allow destructuring, so in the other implementations we use Options to circumvent that.The double wrapped child won't make the process be killed twice, as we set the inner wrapper(
ChildDropGuard
fromtokio/src/process/unix/mod.rs
) to not kill the child on drop (tokio/src/process/unix/mod.rs
line 202), so only the outer one(ChildDropGuard
fromtokio/src/process/mod.rs
) will do that if so set.I tried to make it so there's no double wrapping, but I couldn't make the
PidfdReaper::new
impl work. Because I would have to some way extract the child from the wrapper in thenew
function. And I couldn't get it to work.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is okay if the definition of
ChildDropGuard
needs to move out oftokio/src/process/mod.rs
and into the platform-specific implementation modules, but there is no need to have two wrappers which attempt to perform a kill-on-drop (and bloat the data structures with redundant bools).