Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > gnu.bash.bug > #16437
| From | Chet Ramey <chet.ramey@case.edu> |
|---|---|
| Newsgroups | gnu.bash.bug |
| Subject | Re: Does bash save/restore terminal settings as required by POSIX job control? |
| Date | 2020-06-22 17:19 -0400 |
| Organization | ITS, Case Western Reserve University |
| Message-ID | <mailman.297.1592860796.2574.bug-bash@gnu.org> (permalink) |
| References | <CAB4+JYKZjPPYaNmhLZCDMUhvj9nEfLbaNgX3Q0c+hDHPC2mAew@mail.gmail.com> <fe98cc42-4613-8f30-10c5-66d95a49a6e2@case.edu> |
On 6/22/20 4:48 PM, Godmar Back wrote: > (Disclosure: I performed a search for terminal, terminal settings, > tcsetattr in the bash-bug mailing list, without finding a discussion. > My apologies if this is a known issue or was already discussed.) > > Hi, > > according to POSIX Part A, Base Definitions (line 726-728, pg 20, Part > A: Base Definitions-IEEE and The Open Group.), a job control shell has > the following responsibility: > > "When a foreground (not background) job stops, the shell must sample > and remember the current terminal settings so that it can restore them > later when it continues the stopped job in the foreground (via the > tcgetattr( ) and tcsetattr( ) functions)." > > Does bash implement this functionality? If implemented correctly, I > would expect the program appended below to not fail its assertions. Nobody does this. What job control shells do is to save the tty state after a program's successful termination and use that saved state to restore the tty settings after a program stops or terminates due to a signal. > However, it fails - tested with bash 4.4 on CentOS 8 using a pty > created by sshd. > I also looked at the bash 5.0 source code and could not spot where > bash implements this. You can look at get_tty_state() and set_tty_state() in jobs.c. > I first noticed this when students in my class's shell project failed > to properly implement terminal handling, but programs such vi/vim > still continued to work even when stopped and later placed back in the > foreground. I discovered that these programs implement a SIGCONT > handler where they restore their terminal state when continued, but I > wrote this off as an attempt to be robust in the presence of buggy > shells. This is how programs that modify terminal settings, like editors or more/less pagers, do things. It's standard behavior. -- ``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/
Back to gnu.bash.bug | Previous | Next | Find similar
Re: Does bash save/restore terminal settings as required by POSIX job control? Chet Ramey <chet.ramey@case.edu> - 2020-06-22 17:19 -0400
csiph-web