Skip to content

Slow (10s) startup when shell startup file flushes TTY #4789

@krobelus

Description

@krobelus

Is there an existing issue for this?

  • I have searched the existing issues

Midnight Commander version and build configuration

$ mc -V
GNU Midnight Commander 4.8.33-365-g05a6cf97e

Operating system

Linux

Is this issue reproducible using the latest version of Midnight Commander?

  • I confirm the issue is still reproducible with the latest version of Midnight Commander

How to reproduce

Run this shell script

gcc -xc - <<'EOF'
#include <assert.h>
#include <termios.h>
#include <fcntl.h>
#include <unistd.h>

int
main (void)
{
    int ttyfd = STDOUT_FILENO;
    assert (isatty (ttyfd));
    int ftty = open ("/dev/tty", O_RDWR | O_NOCTTY | O_CLOEXEC);
    assert (ftty >= 0);
    static struct termios oldTerm;
    int ok;
    ok = tcgetattr (ftty, &oldTerm) != -1;
    assert (ok);
    ok = tcsetattr (ftty, TCSAFLUSH, &oldTerm) != -1;
    assert (ok);
}
EOF
echo '[ -n "$MC_SID" ] && '"$PWD"'/a.out' >> ~/.bashrc
SHELL=$(which bash) mc

Expected behavior

mc should start quickly

Actual behavior

mc hangs for 10 seconds, apparently because the ./a.out process has flushed the TTY, so mc can't read the prompt.

Additional context

Originally reported in #4766
This happens on Garuda Linux which configures its shell (fish) to run the "fastfetch" program on startup (if interactive).
That program flushes the TTY like above in a function called ffDetectTerminalSize, called when they want to output an image to the TTY.
I'm not yet sure if this could be fixed in "fastfetch" rather than mc.
cc @egmontkob

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: ttyInteraction with the terminal, screen librariesprio: mediumHas the potential to affect progress

    Type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions