Always stop cosmic-session.target when the process exits/panics

This commit is contained in:
Lucy 2022-07-15 11:05:23 -04:00
parent 9bc295b2ad
commit 8fc34b75b4
No known key found for this signature in database
GPG key ID: EBC517FAD666BBF1
3 changed files with 8 additions and 0 deletions

View file

@ -40,6 +40,12 @@ async fn main() -> Result<()> {
systemd::start_systemd_target()
.await
.wrap_err("failed to start systemd target")?;
// Always stop the target when the process exits or panics.
scopeguard::defer! {
if let Ok(manager) = systemd_client::manager::build_blocking_proxy() {
manager.stop_unit("cosmic-session.target", "replace").ok();
}
}
let env_vars = env_rx
.await
.expect("failed to receive environmental variables")