add a helpful msg to indicate a job has been frozen (#15206)

# Description
As stated in the title, when pressing ctrl-z, I sometimes feel confused
because I return to the REPL without any message. I don't know if the
process has been killed or suspended.

This PR aims to add a message to notify the user that the process has
been frozen.

# User-Facing Changes
After pressing `ctrl-z`.  A message will be printed in repl.


![图片](https://github.com/user-attachments/assets/5fe502eb-439e-4022-889f-64ba52cc2825)

# Tests + Formatting
NaN

# After Submitting
NaN
This commit is contained in:
Wind 2025-03-07 00:20:58 +08:00 committed by GitHub
parent 0e6e9abc12
commit 7d17c2eb5e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 1 deletions

View File

@ -144,6 +144,9 @@ fn unfreeze_job(
jobs.add_job_with_id(old_id, Job::Frozen(FrozenJob { unfreeze: handle }))
.expect("job was supposed to be removed");
if state.is_interactive {
println!("\nJob {} is re-frozen", old_id.get());
}
Ok(())
}

View File

@ -313,6 +313,7 @@ impl Command for External {
let jobs = engine_state.jobs.clone();
let this_job = engine_state.current_thread_job.clone();
let is_interactive = engine_state.is_interactive;
let child_pid = child.pid();
// Wrap the output into a `PipelineData::ByteStream`.
@ -330,7 +331,10 @@ impl Command for External {
if let ForegroundWaitStatus::Frozen(unfreeze) = status {
let mut jobs = jobs.lock().expect("jobs lock is poisoned!");
jobs.add_job(Job::Frozen(FrozenJob { unfreeze }));
let job_id = jobs.add_job(Job::Frozen(FrozenJob { unfreeze }));
if is_interactive {
println!("\nJob {} is frozen", job_id.get());
}
}
}))),
)?;