Skip to content

Commit 34d4bab

Browse files
committed
fix(cli): handle platform-specific SSH cancellation lints
Signed-off-by: Drew Newberry <anewberry@nvidia.com>
1 parent f45c33a commit 34d4bab

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

  • crates/openshell-cli/src

‎crates/openshell-cli/src/ssh.rs‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,10 +232,11 @@ fn ssh_base_command(proxy_command: &str) -> Command {
232232
command
233233
}
234234

235-
async fn exec_or_wait(mut command: Command, replace_process: bool) -> Result<i32> {
235+
async fn exec_or_wait(command: Command, replace_process: bool) -> Result<i32> {
236236
if replace_process && std::io::stdin().is_terminal() {
237237
#[cfg(unix)]
238238
{
239+
let mut command = command;
239240
let err = command.exec();
240241
return Err(miette::miette!("failed to exec ssh: {err}"));
241242
}
@@ -328,13 +329,17 @@ struct ConnectCancellation {
328329
}
329330

330331
impl ConnectCancellation {
332+
// Unix signal registration is fallible; retain the shared API on Windows.
333+
#[cfg_attr(not(unix), allow(clippy::unnecessary_wraps))]
331334
fn new() -> Result<Self> {
332335
Ok(Self {
333336
#[cfg(unix)]
334337
signals: TerminationSignals::new()?,
335338
})
336339
}
337340

341+
// Waiting consumes mutable signal state only on Unix.
342+
#[cfg_attr(not(unix), allow(clippy::needless_pass_by_ref_mut))]
338343
async fn wait<F, T>(&mut self, future: F) -> std::result::Result<T, i32>
339344
where
340345
F: Future<Output = T>,
@@ -380,6 +385,8 @@ async fn terminate_and_reap_child(child: &mut Child, signal: Signal) -> Result<i
380385
Ok(128 + signal as i32)
381386
}
382387

388+
// The shared cancellation state is mutated by the Unix signal receiver.
389+
#[cfg_attr(not(unix), allow(clippy::needless_pass_by_ref_mut))]
383390
async fn run_main_attach_supervised(
384391
session: &SshSessionConfig,
385392
cancellation: &mut ConnectCancellation,

0 commit comments

Comments
 (0)