调整终端大小时,Ncurses程序退出 [英] Ncurses program exits when terminal resized

查看:81
本文介绍了调整终端大小时,Ncurses程序退出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我调整终端窗口的大小时,以下程序退出.为什么以及如何阻止它?

When i resize my terminal window, the below program exits. Why and how can stop it?

#include <ncurses.h>
#include <unistd.h>

int main () {
    initscr ();

    printw ("Some text\n");
    refresh ();

    sleep (100);
    endwin ();

    return 0;
}

推荐答案

我找到了答案调整端子大小后,SIGWINCH信号升高,程序退出.

When terminal has resized, the SIGWINCH signal raises and program exits.

这是解决方案:

#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;
}

这篇关于调整终端大小时,Ncurses程序退出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆