当我调整终端窗口大小时,以下程序退出。为什么以及如何阻止它?
#include <ncurses.h>
#include <unistd.h>
int main () {
initscr ();
printw ("Some text\n");
refresh ();
sleep (100);
endwin ();
return 0;
}
我找到了答案here https://stackoverflow.com/questions/4738803/resize-terminal-and-scrolling-problem-with-ncurses
当终端调整大小时,SIGWINCH
信号上升并且程序退出。
这是解决方案:
#include <ncurses.h>
#include <unistd.h>
#include <signal.h>
int main () {
initscr ();
signal (SIGWINCH, NULL);
printw ("Some text\n");
refresh ();
sleep (100);
endwin ();
return 0;
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)