Search code examples
c++posixncurses

Invalid content when nCurses app comes from background


I have observed odd behavior with my nCurses app when putting it to background/foreground. After a couple of times my window shows invalid content. I suspect that when sending SIGSTOP/SIGCONT signals to my app I need to be handle those and refresh window, but I can't find any note about it. Does nCurses has some way of refreshing window when coming back from background? Or the reason can be different?


Solution

  • ncurses does have a handler for SIGTSTP, which it sets up in initscr — if it is in the default state:

    SIGTSTP
    This handles the stop signal, used in job control. When resuming the process, this implementation discards pending input with flushinput (see curs_util(3x)), and repaints the screen assuming that it has been completely altered. It also updates the saved terminal modes with def_shell_mode (see curs_kernel(3x))