fix stale process count after interrupt
Don't abort the tokio task when killing processes — let SIGTERM'd processes exit normally so run_bash sees the exit and unregisters them from the tracker. Only abort the turn when no processes are running (e.g. interrupting a streaming response). Co-Authored-By: Proof of Concept <poc@bcachefs.org>
This commit is contained in:
parent
ef7dd59b7e
commit
a360607fad
1 changed files with 12 additions and 8 deletions
|
|
@ -547,14 +547,18 @@ impl Session {
|
|||
for p in &procs {
|
||||
self.process_tracker.kill(p.pid).await;
|
||||
}
|
||||
if let Some(handle) = self.turn_handle.take() {
|
||||
handle.abort();
|
||||
self.turn_in_progress = false;
|
||||
self.dmn = dmn::State::Resting {
|
||||
since: Instant::now(),
|
||||
};
|
||||
self.update_status();
|
||||
let _ = self.ui_tx.send(UiMessage::Activity(String::new()));
|
||||
// Only abort the turn if no processes are running — let SIGTERM'd
|
||||
// processes exit normally so run_bash can unregister them.
|
||||
if procs.is_empty() {
|
||||
if let Some(handle) = self.turn_handle.take() {
|
||||
handle.abort();
|
||||
self.turn_in_progress = false;
|
||||
self.dmn = dmn::State::Resting {
|
||||
since: Instant::now(),
|
||||
};
|
||||
self.update_status();
|
||||
let _ = self.ui_tx.send(UiMessage::Activity(String::new()));
|
||||
}
|
||||
}
|
||||
self.pending_input = None;
|
||||
let killed = procs.len();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue