From 629596964e5160a44d21e22cc59a5d80992a52ed Mon Sep 17 00:00:00 2001 From: Timothy DeHerrera Date: Thu, 18 Nov 2021 10:45:31 -0700 Subject: ensure spawned thread exits before main --- src/deploy.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/deploy.rs b/src/deploy.rs index f8fc2f9..5c4b656 100644 --- a/src/deploy.rs +++ b/src/deploy.rs @@ -363,7 +363,7 @@ pub async fn deploy_profile( let (send_activate, recv_activate) = tokio::sync::oneshot::channel(); let (send_activated, recv_activated) = tokio::sync::oneshot::channel(); - tokio::spawn(async move { + let thread = tokio::spawn(async move { let o = ssh_activate.wait_with_output().await; let maybe_err = match o { @@ -399,6 +399,10 @@ pub async fn deploy_profile( let c = confirm_profile(deploy_data, deploy_defs, temp_path, &ssh_addr).await; recv_activated.await.unwrap(); c?; + + thread + .await + .map_err(|x| DeployProfileError::SSHActivate(x.into()))?; } Ok(()) -- cgit v1.2.3