aboutsummaryrefslogtreecommitdiffstats
path: root/crates/turtle/src/command/client/daemon.rs
diff options
context:
space:
mode:
authorBenedikt Peetz <benedikt.peetz@b-peetz.de>2026-06-13 00:50:54 +0200
committerBenedikt Peetz <benedikt.peetz@b-peetz.de>2026-06-13 00:50:54 +0200
commit6723829a3398b3c9dd6dc6ae79124f46000606ee (patch)
treea1ec535eddd711a4557e4bcc5b94382c3623504c /crates/turtle/src/command/client/daemon.rs
parentchore(treewide): Cleanup themes (diff)
downloadatuin-6723829a3398b3c9dd6dc6ae79124f46000606ee.zip
chore(treewide): Remove `cargo` warnings to 0
There are still the `clippy` warnings, but they are for a future date.
Diffstat (limited to 'crates/turtle/src/command/client/daemon.rs')
-rw-r--r--crates/turtle/src/command/client/daemon.rs51
1 files changed, 11 insertions, 40 deletions
diff --git a/crates/turtle/src/command/client/daemon.rs b/crates/turtle/src/command/client/daemon.rs
index 41cb04fe..4960dacd 100644
--- a/crates/turtle/src/command/client/daemon.rs
+++ b/crates/turtle/src/command/client/daemon.rs
@@ -120,7 +120,7 @@ impl PidfileGuard {
impl Drop for PidfileGuard {
fn drop(&mut self) {
- let _ = self.file.unlock();
+ drop(self.file.unlock());
}
}
@@ -232,7 +232,7 @@ async fn probe(settings: &Settings) -> Probe {
async fn request_shutdown(settings: &Settings) {
if let Ok(mut client) = connect_client(settings).await {
- let _ = client.shutdown().await;
+ drop(client.shutdown().await);
}
}
@@ -365,7 +365,7 @@ pub(crate) async fn ensure_daemon_running(settings: &Settings) -> Result<()> {
remove_stale_socket_if_present(settings)?;
spawn_daemon_process()?;
- let _ = wait_until_ready(settings, timeout).await?;
+ drop(wait_until_ready(settings, timeout).await?);
drop(startup_lock);
Ok(())
@@ -451,7 +451,7 @@ pub(crate) async fn end_history(
// End succeeded on the running daemon, so avoid replaying it.
// We only restart to make subsequent hook calls target the expected version.
- let _ = restart_daemon(settings).await;
+ drop(restart_daemon(settings).await);
return Ok(());
}
Err(err) if !settings.daemon.autostart => return Err(err),
@@ -679,11 +679,13 @@ fn force_cleanup(settings: &Settings) {
#[cfg(unix)]
fn kill_process(pid: u32) {
// Use kill command to send SIGTERM for graceful shutdown
- let _ = Command::new("kill")
- .args(["-TERM", &pid.to_string()])
- .stdout(Stdio::null())
- .stderr(Stdio::null())
- .status();
+ drop(
+ Command::new("kill")
+ .args(["-TERM", &pid.to_string()])
+ .stdout(Stdio::null())
+ .stderr(Stdio::null())
+ .status(),
+ );
}
#[cfg(test)]
@@ -725,35 +727,4 @@ mod tests {
let lock = daemon_startup_lock_path(pidfile);
assert_eq!(lock, PathBuf::from("/tmp/atuin-daemon.pid.startup.lock"));
}
-
- #[test]
- fn test_pidfile_guard_acquire_and_drop() {
- let tmp = tempfile::tempdir().unwrap();
- let pidfile = tmp.path().join("daemon.pid");
-
- {
- let _guard = PidfileGuard::acquire(&pidfile).unwrap();
- // Guard holds an exclusive lock — on Windows other handles cannot
- // read the file, so we verify contents after the guard is dropped.
- }
-
- let contents = std::fs::read_to_string(&pidfile).unwrap();
- let lines: Vec<&str> = contents.lines().collect();
- assert_eq!(lines.len(), 2);
- assert_eq!(lines[0], std::process::id().to_string());
- assert_eq!(lines[1], DAEMON_VERSION);
-
- // After guard is dropped, lock should be released — acquiring again must succeed.
- let _guard2 = PidfileGuard::acquire(&pidfile).unwrap();
- }
-
- #[test]
- fn test_pidfile_guard_prevents_double_acquire() {
- let tmp = tempfile::tempdir().unwrap();
- let pidfile = tmp.path().join("daemon.pid");
-
- let _guard = PidfileGuard::acquire(&pidfile).unwrap();
- let result = PidfileGuard::acquire(&pidfile);
- assert!(result.is_err());
- }
}