mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-15 22:44:01 +00:00
Stop setting tty back to shell mode when a fg proc completes
Prior to this change, when a process resumes because it is brought back
to the foreground, we would reset the terminal attributes to shell mode.
This fixed #2114 but subtly introduced #7483.
This backs out 9fd9f70346
, re-introducing #2114 and re-fixing #7483.
A followup fix will re-fix #2114; these are broken out separately for
bisecting purposes.
Fixes #7483.
This commit is contained in:
parent
e9b683dee1
commit
db514df95b
2 changed files with 45 additions and 13 deletions
13
src/proc.cpp
13
src/proc.cpp
|
@ -931,19 +931,6 @@ static bool terminal_return_from_job_group(job_group_t *jg, bool restore_attrs)
|
|||
return false;
|
||||
}
|
||||
jg->tmodes = tmodes;
|
||||
|
||||
// Need to restore the terminal's attributes or `bind \cF fg` will put the
|
||||
// terminal into a broken state (until "enter" is pressed).
|
||||
// See: https://github.com/fish-shell/fish-shell/issues/2114
|
||||
if (restore_attrs) {
|
||||
if (tcsetattr(STDIN_FILENO, TCSADRAIN, &shell_modes) == -1) {
|
||||
if (errno == EIO) redirect_tty_output();
|
||||
FLOGF(warning, _(L"Could not return shell to foreground"));
|
||||
wperror(L"tcsetattr");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
45
tests/pexpects/fg2.py
Normal file
45
tests/pexpects/fg2.py
Normal file
|
@ -0,0 +1,45 @@
|
|||
#!/usr/bin/env python3
|
||||
from pexpect_helper import SpawnedProc
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
|
||||
sp = SpawnedProc()
|
||||
send, sendline, sleep, expect_prompt, expect_re, expect_str = (
|
||||
sp.send,
|
||||
sp.sendline,
|
||||
sp.sleep,
|
||||
sp.expect_prompt,
|
||||
sp.expect_re,
|
||||
sp.expect_str,
|
||||
)
|
||||
expect_prompt()
|
||||
|
||||
# Regression test for #7483.
|
||||
# Ensure we can background a job after a different backgrounded job completes.
|
||||
sendline("sleep 1")
|
||||
sleep(0.1)
|
||||
|
||||
# ctrl-z - send job to background
|
||||
send("\x1A")
|
||||
sleep(0.2)
|
||||
expect_prompt("has stopped")
|
||||
|
||||
# Bring back to fg.
|
||||
sendline("fg")
|
||||
sleep(1.0)
|
||||
|
||||
# Now sleep is done, right?
|
||||
expect_prompt()
|
||||
sendline("jobs")
|
||||
expect_prompt("jobs: There are no jobs")
|
||||
|
||||
# Ensure we can do it again.
|
||||
sendline("sleep 5")
|
||||
sleep(0.2)
|
||||
send("\x1A")
|
||||
sleep(0.1)
|
||||
expect_prompt("has stopped")
|
||||
sendline("fg")
|
||||
sleep(0.1) # allow tty to transfer
|
||||
send("\x03") # control-c to cancel it
|
Loading…
Reference in a new issue