The pixel information obtained by TIOCGWINSZ is incorrect. #22544

Open
opened 2026-01-31 08:16:17 +00:00 by claunia · 0 comments
Owner

Originally created by @mikoto2000 on GitHub (Nov 14, 2024).

Windows Terminal version

1.22.2912.0

Windows build number

10.0.22631.0

Other Software

My application.

termsize.c:

#include <fcntl.h>
#include <termios.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/ioctl.h>

void main() {
  struct winsize ws;
  int fd = open("/dev/tty", O_RDONLY);
  if(fd == -1) {
    fprintf(stderr, "Can't open tty");
    return;
  }
  int ret = ioctl(fd, TIOCGWINSZ, &ws);
  close(fd);
  fprintf(stderr, "cols %d rows %d, xpixel %d, ypixel %d.\n", ws.ws_col, ws.ws_row, ws.ws_xpixel, ws.ws_ypixel);
}

Steps to reproduce

  1. Run gcc termsize.c -o termsize && ./termsize
  2. Output stderr cols 163 rows 60, xpixel 0, ypixel 0. † xpixel and ypixel is fixed value zero.

(I was recommended to ask here in the comments at https://github.com/microsoft/WSL/issues/12265, so I am asking here as well.)

Expected Behavior

Output xpixel and ypixel is correct value.

Actual Behavior

Output xpixel and ypixel is fixed value zero.

Originally created by @mikoto2000 on GitHub (Nov 14, 2024). ### Windows Terminal version 1.22.2912.0 ### Windows build number 10.0.22631.0 ### Other Software My application. termsize.c: ```c #include <fcntl.h> #include <termios.h> #include <stdio.h> #include <unistd.h> #include <sys/ioctl.h> void main() { struct winsize ws; int fd = open("/dev/tty", O_RDONLY); if(fd == -1) { fprintf(stderr, "Can't open tty"); return; } int ret = ioctl(fd, TIOCGWINSZ, &ws); close(fd); fprintf(stderr, "cols %d rows %d, xpixel %d, ypixel %d.\n", ws.ws_col, ws.ws_row, ws.ws_xpixel, ws.ws_ypixel); } ``` ### Steps to reproduce 1. Run `gcc termsize.c -o termsize && ./termsize` 2. Output stderr `cols 163 rows 60, xpixel 0, ypixel 0.` † xpixel and ypixel is fixed value zero. (I was recommended to ask here in the comments at https://github.com/microsoft/WSL/issues/12265, so I am asking here as well.) ### Expected Behavior Output xpixel and ypixel is correct value. ### Actual Behavior Output xpixel and ypixel is fixed value zero.
claunia added the Issue-BugResolution-Duplicate labels 2026-01-31 08:16:17 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#22544