Fix clippy warnings and format code

- Fix redundant closure warning in api_server.rs
- Add backticks to login_tty in documentation comments
- All clippy warnings resolved
This commit is contained in:
Peter Steinberger 2025-06-18 14:16:43 +02:00
parent f0658bccd0
commit 5f067c7a80
2 changed files with 14 additions and 10 deletions

View file

@ -1045,9 +1045,10 @@ fn handle_session_kill(control_path: &Path, path: &str) -> Response<String> {
let mut process_died = false; let mut process_died = false;
if let Ok(content) = std::fs::read_to_string(&session_json_path) { if let Ok(content) = std::fs::read_to_string(&session_json_path) {
if let Ok(session_info) = serde_json::from_str::<serde_json::Value>(&content) { if let Ok(session_info) = serde_json::from_str::<serde_json::Value>(&content) {
if let Some(pid) = session_info.get("pid").and_then(|p| p.as_u64()) { if let Some(pid) = session_info.get("pid").and_then(serde_json::Value::as_u64) {
// Wait for the process to actually die // Wait for the process to actually die
for _ in 0..30 { // 30 * 100ms = 3 seconds max for _ in 0..30 {
// 30 * 100ms = 3 seconds max
if !sessions::is_pid_alive(pid as u32) { if !sessions::is_pid_alive(pid as u32) {
process_died = true; process_died = true;
break; break;
@ -1072,9 +1073,12 @@ fn handle_session_kill(control_path: &Path, path: &str) -> Response<String> {
if process_died { if process_died {
(StatusCode::OK, "Session killed") (StatusCode::OK, "Session killed")
} else { } else {
(StatusCode::OK, "Session kill signal sent (process may still be terminating)") (
StatusCode::OK,
"Session kill signal sent (process may still be terminating)",
)
} }
}, }
Err(e) => { Err(e) => {
let response = ApiResponse { let response = ApiResponse {
success: None, success: None,

View file

@ -43,8 +43,8 @@ use tempfile::NamedTempFile;
pub const DEFAULT_TERM: &str = "xterm-256color"; pub const DEFAULT_TERM: &str = "xterm-256color";
/// Cross-platform implementation of login_tty /// Cross-platform implementation of `login_tty`
/// On systems with login_tty, use it directly. Otherwise, implement manually. /// On systems with `login_tty`, use it directly. Otherwise, implement manually.
#[cfg(any( #[cfg(any(
target_os = "macos", target_os = "macos",
target_os = "freebsd", target_os = "freebsd",