get console window width: why ioctl always return 0 width?
Hi, all,
I use ioctl to get the cosole window size (the SSH window). I use the following code:
-------------
struct winsize ws;
int returnValue = ioctl(pCommandStructure->terminal, TIOCGWINSZ, &ws);
int numberOfColumnsOfTerminalWindow = ws.ws_col;
-------------
When I debug on linux pc, it gives me the correct window width. But after I try it on router (this is my enventual place where my code shall run), ioctl always give me 0 width, that is, numberOfColumnsOfTerminalWindow == 0. but the returnValue is 0 which means that the function call succeeds.
Can anyonen tell me what is the problem and how to solve it?
Thanks a lot.
|