|
@@ -0,0 +1,41 @@
|
|
1
|
+#include <sys/ioctl.h>
|
|
2
|
+#include <stdio.h>
|
|
3
|
+#include <unistd.h>
|
|
4
|
+#include <signal.h>
|
|
5
|
+#include <stdlib.h>
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+void foo(int signum) {
|
|
9
|
+// printf("wowo %d\n",signum);
|
|
10
|
+ //exit(signum);
|
|
11
|
+ int cols = 80;
|
|
12
|
+ int lines = 24;
|
|
13
|
+#ifdef TIOCGSIZE
|
|
14
|
+ struct ttysize ts;
|
|
15
|
+ ioctl(STDIN_FILENO, TIOCGSIZE, &ts);
|
|
16
|
+ cols = ts.ts_cols;
|
|
17
|
+ lines = ts.ts_lines;
|
|
18
|
+#elif defined(TIOCGWINSZ)
|
|
19
|
+ struct winsize ts;
|
|
20
|
+ ioctl(STDIN_FILENO, TIOCGWINSZ, &ts);
|
|
21
|
+ cols = ts.ws_col;
|
|
22
|
+ lines = ts.ws_row;
|
|
23
|
+#endif /* TIOCGSIZE */
|
|
24
|
+
|
|
25
|
+ printf("Terminal is %dx%d\n", cols, lines);
|
|
26
|
+
|
|
27
|
+}
|
|
28
|
+
|
|
29
|
+int main (void)
|
|
30
|
+{
|
|
31
|
+
|
|
32
|
+(void)signal(SIGWINCH,foo);
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+ while(1) {
|
|
38
|
+ }
|
|
39
|
+}
|
|
40
|
+
|
|
41
|
+
|