LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   get console window width: why ioctl always return 0 width? (https://www.linuxquestions.org/questions/programming-9/get-console-window-width-why-ioctl-always-return-0-width-817399/)

karatelambda 07-01-2010 08:37 AM

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.

smoker 07-02-2010 12:08 PM

There is no window on the router. So it will always be 0 width. Unless you have some kind of GUI running on the router ?

karatelambda 07-07-2010 07:57 AM

Thank you for reply. I use PuTTY to login to this router. I mean the window size of this console window. Any idea?


All times are GMT -5. The time now is 05:46 AM.