[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: fg via keybind modifies tty settings
From: |
Chet Ramey |
Subject: |
Re: fg via keybind modifies tty settings |
Date: |
Tue, 24 Sep 2024 10:21:04 -0400 |
User-agent: |
Mozilla Thunderbird |
On 9/20/24 7:23 PM, David Moberg wrote:
Bash Version: 5.2
Patch Level: 21
Release Status: release
Description:
When a process/job is suspended, foregrounded via ctrl-a as a
keybinding for fg, and then
suspended again, the tty will be in a surprising state where no
input is seen (-echo)
When the shell starts a job with `fg', it fetches the tty settings so it
can restore them if the job exits or stops due to a signal. That way, a
job that modifies the terminal settings, then crashes, doesn't leave the
terminal in an unusable state.
When you run a command from a readline key binding, it still runs in the
context of readline obtaining a line from the keyboard -- it's just another
key binding, like C-f. Readline doesn't reset the tty settings to run the
binding, and bash doesn't reset them to run the command.
When `fg' runs and starts the job, the shell fetches the tty settings as
usual, but they are the tty settings readline uses when it's reading input.
It assumes those are the `normal' settings.
When vim stops due to the SIGTSTP, the shell restores what it thinks are
the normal tty settings -- the ones it fetched after readline modified
them. The difference you see between the `working' and `broken' settings
is what readline does so it can read input.
I will see if this can be changed by having `fg' detect whether it's
being run from a key binding and not fetch the terminal settings in that
case.
Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU chet@case.edu http://tiswww.cwru.edu/~chet/