Only set modes after config.fish if we're *interactive*

013a563ed0 made it so we only try to
adjust terminal modes if we are in the terminal pgroup, but that's not
enough.

Fish starts background jobs in events inside its own pgroup, so

    function on-foo --on-event foo
        fish -c 'sleep 3' &
    end

would have the backgrounded fish try to fiddle with the terminal and
succeed.

Instead, only fiddle with the terminal if we're interactive (this
should probably be extended to other bits, but this is the particular
problematic part)

Fixes #7842.

(cherry picked from commit e4fd664bbb)
This commit is contained in:
Fabian Homborg 2021-03-21 10:26:04 +01:00 committed by David Adam
parent b2baf110c5
commit 9221a3deca

View file

@ -1342,7 +1342,7 @@ void reader_init() {
// Set up our fixed terminal modes once,
// so we don't get flow control just because we inherited it.
if (getpgrp() == tcgetpgrp(STDIN_FILENO)) {
if (is_interactive_session()) {
term_donate(/* quiet */ true);
}