Use tokio to asynchronously read from pipe

Avoids either `spawn_blocking`, or potentially blocking call in an async
function (though it shouldn't block for long).
This commit is contained in:
Ian Douglas Scott 2024-07-25 09:26:54 -07:00 committed by Ian Douglas Scott
parent 621de17cad
commit 82fb781746
2 changed files with 8 additions and 12 deletions

View file

@ -335,7 +335,7 @@ where
// https://systemd.io/DESKTOP_ENVIRONMENTS
//
// Similar to what Gnome sets, for now.
if let Ok(Some(pid)) = tokio::task::spawn_blocking(|| crate::process::spawn(cmd)).await {
if let Some(pid) = crate::process::spawn(cmd).await {
if let Ok(session) = zbus::Connection::session().await {
if let Ok(systemd_manager) = SystemdMangerProxy::new(&session).await {
let _ = systemd_manager