Differences between version 2 and predecessor to the previous major change of SIGWINCH.
Other diffs: Previous Revision, Previous Author, or view the Annotated Edit History
Newer page: | version 2 | Last edited on Thursday, February 13, 2003 2:50:01 am | by PerryLorier | Revert |
Older page: | version 1 | Last edited on Saturday, September 28, 2002 2:33:16 pm | by PerryLorier | Revert |
@@ -1,3 +1,26 @@
!!!Signal: __Win__dow size __Ch__ange
This signal is delivered to a process when it's terminal size changes. The default action is to ignore the signal. Usually a process that cares about displaying information on the screen would use the resize information to redraw the screen and update it's idea of how large the screen is.
+
+now, the real question here, is how do you know what the new size of the screen is? the answer is the TIOCGWINSZ ioctl(2).
+
+an example:
+
+ #include <termios.h>
+ #include <sys/ioctl.h>
+ #include <fcntl.h>
+ #include <stdio.h>
+
+ int main(int argc,char **argv)
+ {
+ struct winsize ws;
+ int fd=open("/dev/tty",O_RDWR);
+
+ if (ioctl(fd,TIOCGWINSZ,&ws)!=0) {
+ perror("ioctl(/dev/tty,TIOCGWINSZ)");
+ return 1;
+ }
+ printf("rows %i\n",ws.ws_row);
+ printf("cols %i\n",ws.ws_col);
+ return 0;
+ }