Penguin

Differences between current version and predecessor to the previous major change of SIGWINCH.

Other diffs: Previous Revision, Previous Author, or view the Annotated Edit History

Newer page: version 4 Last edited on Tuesday, March 7, 2006 2:56:54 pm by JohnMcPherson
Older page: version 1 Last edited on Saturday, September 28, 2002 2:33:16 pm by PerryLorier Revert
@@ -1,3 +1,32 @@
 !!!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. 
+This signal is delivered to a process when its 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 its 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:  
+<verbatim>  
+ #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)!=) {  
+ perror("ioctl(/dev/tty,TIOCGWINSZ)");  
+ return 1;  
+ }  
+ printf("rows %i\n",ws.ws_row);  
+ printf("cols %i\n",ws.ws_col);  
+ return ;  
+ }  
+</verbatim>  
+  
+If bash(1) (or zsh(1)...) is the terminal's controlling process when a terminal is resized, it will automatically update the ''$LINES'' and ''$COLUMNS'' variables.  
+  
+  
+My xterm sometimes dies if I resize it while [IRC] is running in it. Presumably, what's happening is that during the resize, the irc client tries to write to the bottom of the xterm and the signal from xterm doesn't get handled in time, causing my xterm (version 156) to "disappear" when the ncurses(3x) library tries to write to a bit of the xterm that's no longer there