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

kill and reap ProxyCommand #5494

Merged
merged 1 commit into from
Jul 15, 2024
Merged

kill and reap ProxyCommand #5494

merged 1 commit into from
Jul 15, 2024

Conversation

daaku
Copy link
Contributor

@daaku daaku commented May 31, 2024

Using the scopeguard crate ensures the child process (if any) spawned for the ProxyCommand is cleaned up under all the various error scenarios (such as auth failures etc), as well as in the normal successful use case. This ensures killing it if necessary, and then waiting for it.

This is a fix for #5479.

Copy link
Owner

@wez wez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this!
I have a slightly different proposal; would you mind updating to match it?

@@ -39,6 +39,7 @@ wezterm-uds = { path = "../wezterm-uds" }

# Not used directly, but is used to centralize the openssl vendor feature selection
async_ossl = { path = "../async_ossl" }
scopeguard = "1.2.0"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

while scopeguard is handy in a pinch, I'm not in favor of it here for a couple of reasons:

  • It is an additional external dependency
  • You still have to remember to initiate the scope guard, and that is required in multiple places in this PR

What I'd prefer to see as a solution for this is for connect_to_host to return a little wrapper around the Child:

struct KillOnDropChild(Child);

impl std::ops::Deref for KillOnDropChild { ... }
impl std::ops::DerefMut for KillOnDropChild { ... }
impl Drop for KillOnDropChild {
   fn drop(&mut self) {
       self.0.kill();
       self.0.wait();
   }
}

@daaku
Copy link
Contributor Author

daaku commented Jul 15, 2024

Sounds reasonable, I'll update with the requested changes.

@daaku
Copy link
Contributor Author

daaku commented Jul 15, 2024

Updated, I think this does the trick without use of scopeguard.

The wrapper struct ensures ensures the child process spawned for
the ProxyCommand is cleaned up under all the various error scenarios
(such as auth failures etc), as well as in the normal successful use
case. This includes killing it if necessary, and then waiting for it.
@wez wez merged commit 463df9e into wez:main Jul 15, 2024
16 of 17 checks passed
@wez
Copy link
Owner

wez commented Jul 15, 2024

Thank you!

wez added a commit that referenced this pull request Jul 15, 2024
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.

2 participants