Search code examples
terminalncurses

Clean up ncurses mess in terminal after a crash


I am drawing a TUI using ncurses. The trouble is that whenever my program gets seg-fault, my terminal is left in mess. I can not see what I am typing. Its a pain since I am working over ssh. I have mitigated some of the effect by using screen.

I would like to know if there is a command which will refresh my terminal after seg-fault in ncurses so that my terminal starts behaving normally.


Solution

  • Command stty sane did the job. If enter doesn't work, you may use ^J.

    stty sane ^J
    

    Sometimes CR/LF interpretation is broken so use the ^J explicitly.