1234567891011121314151617181920212223242526272829303132333435363738394041 |
- #include <sys/ioctl.h>
- #include <stdio.h>
- #include <unistd.h>
- #include <signal.h>
- #include <stdlib.h>
-
-
- void foo(int signum) {
- // printf("wowo %d\n",signum);
- //exit(signum);
- int cols = 80;
- int lines = 24;
- #ifdef TIOCGSIZE
- struct ttysize ts;
- ioctl(STDIN_FILENO, TIOCGSIZE, &ts);
- cols = ts.ts_cols;
- lines = ts.ts_lines;
- #elif defined(TIOCGWINSZ)
- struct winsize ts;
- ioctl(STDIN_FILENO, TIOCGWINSZ, &ts);
- cols = ts.ws_col;
- lines = ts.ws_row;
- #endif /* TIOCGSIZE */
-
- printf("Terminal is %dx%d\n", cols, lines);
-
- }
-
- int main (void)
- {
-
- (void)signal(SIGWINCH,foo);
-
-
-
-
- while(1) {
- }
- }
-
|