[konsole] [Bug 427577] New: Ctrl+Shift+K (Clear Scrollback and Reset) causes TTY to report incorrect size

Roman Perepelitsa bugzilla_noreply at kde.org
Mon Oct 12 09:52:58 BST 2020


https://bugs.kde.org/show_bug.cgi?id=427577

            Bug ID: 427577
           Summary: Ctrl+Shift+K (Clear Scrollback and Reset) causes TTY
                    to report incorrect size
           Product: konsole
           Version: 19.12.3
          Platform: Ubuntu Packages
                OS: Linux
            Status: REPORTED
          Severity: normal
          Priority: NOR
         Component: emulation
          Assignee: konsole-devel at kde.org
          Reporter: roman.perepelitsa at gmail.com
  Target Milestone: ---

SUMMARY

Ctrl+Shift+K (Clear Scrollback and Reset) erroneously sends SIGWINCH to the
shell notifying it that the terminal window has been resized. More
specifically, that the number of columns has been increased by 1.


STEPS TO REPRODUCE

1. Create file `/tmp/testwinch.c` with the following content:

    #include <signal.h>
    #include <stdio.h>
    #include <stdlib.h>
    #include <sys/ioctl.h>
    #include <unistd.h>

    #define CHECK(...)        \
      if ((__VA_ARGS__)) {    \
      } else {                \
        perror(#__VA_ARGS__); \
        exit(1);              \
      }

    static void print_tty_size(const char* when) {
      struct winsize w;
      CHECK(ioctl(STDOUT_FILENO, TIOCGWINSZ, &w) != -1);
      CHECK(printf("%s: %dx%d\n", when, w.ws_row, w.ws_col) >= 0);
    }

    int main(void) {
      sigset_t sigset;
      siginfo_t siginfo;

      CHECK(sigemptyset(&sigset) == 0);
      CHECK(sigaddset(&sigset, SIGWINCH) == 0);
      CHECK(sigprocmask(SIG_BLOCK, &sigset, NULL) == 0);

      print_tty_size("Initial");
      CHECK(sigwaitinfo(&sigset, &siginfo) == SIGWINCH);
      print_tty_size("After WINCH");

      while (1) sleep(1);
    }

2. Run the following command:

    gcc -o /tmp/testwinch /tmp/testwinch.c

3. Start Konsole.

4. Open Settings > Configure Keyboard Shortcuts, set Shortcut for Clear
Scrollback and Reset to Ctrl+Shift+K (this is the default) and click OK.

5. Open Settings > Edit Current Profile, set Command to /tmp/testwinch and
click OK.

6. Click File > New Tab and observe the following output:

7. Press Ctrl+Shift+K.

OBSERVED RESULT

The content of the terminal window after performing step 6:

    Initial: 24x80

The content of the terminal window after performing step 7:

    After WINCH: 24x81

Note the difference in dimensions (81 vs 80 columns).

EXPECTED RESULT

The content of the terminal window after performing step 6:

    Initial: 24x80

The content of the terminal window after performing step 7:

    After WINCH: 24x80

Note that the dimension stays the same (24x80 columns).

SOFTWARE/OS VERSIONS
OS: Ubuntu 20.04.1 LTS
KDE Frameworks Version: 5.68.0
Qt Version: 5.12.8 (built against 5.12.8)

ADDITIONAL INFORMATION

The same issue can be reproduced by using zsh instead of a custom program.

1. Start Konsole.

2. Open Settings > Configure Keyboard Shortcuts, set Shortcut for Clear
Scrollback and Reset to Ctrl+Shift+K (this is the default) and click OK.

3. Run the following command:

    RPS1='$(typeset -p COLUMNS >&2)' zsh -f --promptsubst

4. Press Ctrl+Shift+K.

Actual output:

    hostname% typeset -i10 COLUMNS=81
    hostname% typeset -i10 COLUMNS=80

Expected output:

    hostname% typeset -i10 COLUMNS=80
    hostname% typeset -i10 COLUMNS=80

-- 
You are receiving this mail because:
You are the assignee for the bug.


More information about the konsole-devel mailing list