I'm writing a simple application to use ptys and run commands such as vi. When they run, regardless of my terminal emulator's size, the pty runs on a very small window; here's a screenshot: https://i.stack.imgur.com/DfvNo.jpg the cursor is just outside the pty (and the screen is blank, nothing is written outside it).
Keeping the terminal emulator at a maximum size, I aim to "extend" the pty's size and use the full screen.
My approach was to get the size for stdout and set it on the master size of the terminal, following what I read here: Can't change terminal size on pty/N (works on ttyN)
#define err(x) { if((x)==-1) exit(1); }
int set(int masterfd) {
float k = 0;
struct winsize w;
err(ioctl(STDOUT_FILENO, TIOCGWINSZ, &w));
printf("wsz: r:%d c:%d\n", w.ws_row, w.ws_col);
w.ws_row *= k; w.ws_col *= k;
err(ioctl(masterfd, TIOCSWINSZ, &w));
return 1;
}
When k
is non-zero, the whole screen is messed up. Only when both rows and columns are zero, the terminal is tiny but works.
After opening the master, I was expecting a call to set()
with the master fd to adjust the size of the terminal. The call to printf()
shows that on STDOUT_FILENO
the rows and columns are my display size, on the master fd they are 0.
How can I make the pty use my full screen?