Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,20 +292,27 @@ impl App {
}

/// Confirm and execute a pending signal action.
pub fn confirm_signal(&mut self, sender: &mut dyn FnMut(i32, Signal) -> Result<(), String>) {
let Some(pending) = self.pending_confirmation.take() else {
return;
};
///
/// Returns `Some(pid)` when the sender accepted the signal so callers can
/// follow up (e.g. wait for the kernel to remove the entry from `/proc`).
/// Returns `None` when no confirmation was pending or the sender failed.
pub fn confirm_signal(
&mut self,
sender: &mut dyn FnMut(i32, Signal) -> Result<(), String>,
) -> Option<i32> {
let pending = self.pending_confirmation.take()?;

match sender(pending.pid, pending.signal) {
Ok(()) => {
self.status = format!(
"sent {:?} ({}) to pid {}",
pending.signal, pending.digit, pending.pid
);
Some(pending.pid)
}
Err(err) => {
self.status = format!("failed to signal pid {}: {}", pending.pid, err);
None
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/debug_tui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ pub(crate) fn run() -> Result<()> {
build_debug_rows(seed.get())
};
let mut sender = debug_signal_sender;
let mut await_pid_gone = |_pid: i32| {};
let mut app = App::with_rows(None, initial_rows);
app.status = "debug tui: synthetic rows only".to_string();
let result = run_event_loop(
Expand All @@ -65,6 +66,7 @@ pub(crate) fn run() -> Result<()> {
&mut next_event,
&mut refresh_rows,
&mut sender,
&mut await_pid_gone,
);
restore_terminal(terminal);
result
Expand Down
Loading