pty-shell
pty-shell copied to clipboard
ioctl(2) can't gets the window' size from a pty-shell' child
Hello @hibariya! Today, I report this:
According to the documentation I have executed a default bash' shell.
When I request the window size's information from this shell, I get the default values.
> echo -e "lines\ncols" | tput -S
24
80
When I request the window size's information from a sub-program of shell, I get a empty structure winsize.
> ./size
winsize: [0; 0]
> echo $? # ioctl(2) hasn't occurred an error.
0
The code source used for this example is:
#include <sys/ioctl.h>
#include <stdio.h>
int main(void)
{
struct winsize winsz;
if (ioctl(0, TIOCGWINSZ, &winsz) != 0)
{
return -1;
}
printf("winsize: [%d; %d]\n", winsz.ws_row, winsz.ws_col);
return 0;
}
I will more investigate later.