【发布时间】:2017-01-08 16:47:55
【问题描述】:
我有一个程序,我在其中使用 ioctl(0, TIOCGWINSZ, (struct winsize *)) 来查找程序正在运行的终端窗口的大小。当我在终端中运行它时,它工作正常,但是当我使用 LLDB 时,ioctl 给出窗口大小为 0 x 0。
例子:
#include <unistd.h>
#include <sys/ioctl.h>
#include <stdio.h>
int main(){
struct winsize tty_window_size;
ioctl(STDOUT_FILENO, TIOCGWINSZ, &tty_window_size);
printf("Rows: %i, Cols: %i\n", tty_window_size.ws_row, tty_window_size.ws_col);
return 0;
}
终端成绩单:
$ clang test.c
$ ./a.out
Rows: 24, Cols: 80
$ lldb ./a.out
(lldb) target create "./a.out"
Current executable set to './a.out' (x86_64).
(lldb) r
Process 32763 launched: './a.out' (x86_64)
Rows: 0, Cols: 0
Process 32763 exited with status = 0 (0x00000000)
有人知道为什么会发生这种情况,或者有解决方法吗?
提前致谢。
【问题讨论】: