mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-25 20:33:08 +00:00
Improved warning message when exiting with jobs still active
Fixes #4303
This commit is contained in:
parent
7b92217273
commit
5ceac038b1
2 changed files with 31 additions and 6 deletions
|
@ -2178,6 +2178,21 @@ bool shell_is_exiting() {
|
|||
return end_loop;
|
||||
}
|
||||
|
||||
static void bg_job_warning() {
|
||||
fputws(_(L"There are still jobs active:\n"), stdout);
|
||||
fputws(_(L"\n PID Command\n"), stdout);
|
||||
|
||||
job_iterator_t jobs;
|
||||
while (job_t *j = jobs.next()) {
|
||||
if (!job_is_completed(j)) {
|
||||
fwprintf(stdout, L"%6d %ls\n", j->pgid, j->command_wcstr());
|
||||
}
|
||||
}
|
||||
fputws(L"\n", stdout);
|
||||
fputws(_(L"Use `disown PID` to let them live independently from fish.\n"), stdout);
|
||||
fputws(_(L"A second attempt to exit will terminate them.\n"), stdout);
|
||||
}
|
||||
|
||||
/// This function is called when the main loop notices that end_loop has been set while in
|
||||
/// interactive mode. It checks if it is ok to exit.
|
||||
static void handle_end_loop() {
|
||||
|
@ -2202,8 +2217,7 @@ static void handle_end_loop() {
|
|||
}
|
||||
|
||||
if (!data->prev_end_loop && bg_jobs) {
|
||||
fputws(_(L"There are still jobs active (use the jobs command to see them).\n"), stdout);
|
||||
fputws(_(L"A second attempt to exit will terminate them.\n"), stdout);
|
||||
bg_job_warning();
|
||||
reader_exit(0, 0);
|
||||
data->prev_end_loop = 1;
|
||||
return;
|
||||
|
|
|
@ -9,8 +9,13 @@ expect_prompt
|
|||
send "sleep 111 &\r"
|
||||
expect_prompt
|
||||
send "exit\r"
|
||||
expect "There are still jobs active"
|
||||
expect "A second attempt to exit will terminate them."
|
||||
expect -re "There are still jobs active:\r
|
||||
\r
|
||||
PID Command\r
|
||||
*\\d+ sleep 111 &\r
|
||||
\r
|
||||
Use `disown PID` to let them live independently from fish.\r
|
||||
A second attempt to exit will terminate them.\r"
|
||||
expect_prompt
|
||||
|
||||
# Running anything other than `exit` should result in the same warning with
|
||||
|
@ -18,8 +23,14 @@ expect_prompt
|
|||
send "sleep 113 &\r"
|
||||
expect_prompt
|
||||
send "exit\r"
|
||||
expect "There are still jobs active"
|
||||
expect "A second attempt to exit will terminate them."
|
||||
expect -re "There are still jobs active:\r
|
||||
\r
|
||||
PID Command\r
|
||||
*\\d+ sleep 113 &\r
|
||||
*\\d+ sleep 111 &\r
|
||||
\r
|
||||
Use `disown PID` to let them live independently from fish.\r
|
||||
A second attempt to exit will terminate them.\r"
|
||||
expect_prompt
|
||||
|
||||
# Verify that asking to exit a second time does so.
|
||||
|
|
Loading…
Reference in a new issue