✨ Always stop cosmic-session.target when the process exits/panics
This commit is contained in:
parent
9bc295b2ad
commit
8fc34b75b4
3 changed files with 8 additions and 0 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
|
@ -241,6 +241,7 @@ dependencies = [
|
||||||
"futures-util",
|
"futures-util",
|
||||||
"libc",
|
"libc",
|
||||||
"nix 0.24.1",
|
"nix 0.24.1",
|
||||||
|
"scopeguard",
|
||||||
"sendfd",
|
"sendfd",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ color-eyre = "0.6"
|
||||||
futures-util = "0.3"
|
futures-util = "0.3"
|
||||||
libc = "0.2"
|
libc = "0.2"
|
||||||
nix = { version = "0.24", features = ["fs"], default-features = false }
|
nix = { version = "0.24", features = ["fs"], default-features = false }
|
||||||
|
scopeguard = "1.1.0"
|
||||||
sendfd = { version = "0.4", features = ["tokio"] }
|
sendfd = { version = "0.4", features = ["tokio"] }
|
||||||
serde = { version = "1", features = ["derive"] }
|
serde = { version = "1", features = ["derive"] }
|
||||||
serde_json = "1"
|
serde_json = "1"
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,12 @@ async fn main() -> Result<()> {
|
||||||
systemd::start_systemd_target()
|
systemd::start_systemd_target()
|
||||||
.await
|
.await
|
||||||
.wrap_err("failed to start systemd target")?;
|
.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
|
let env_vars = env_rx
|
||||||
.await
|
.await
|
||||||
.expect("failed to receive environmental variables")
|
.expect("failed to receive environmental variables")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue