6

I am using the Linux framebuffer in my application, and setting ioctl(tty0_fd, KDSETMODE, KD_GRAPHICS) to prevent any cursor or text from being displayed by the underlying terminal, and then cleaning up upon normal program termination.

But remaining in KD_GRAPHICS mode upon abnormal termination is a Bad Thing since it leaves the system unresponsive, and I'm wondering how to address that condition.

Functions registered with atexit() are only invoked upon normal termination, so that won't help. I could register my own handlers for any signals that can kill the application, but SIGKILL cannot be trapped.

How do windowing environments and other programs handle this situation?

Josh Sanford
  • 622
  • 5
  • 18

1 Answers1

1

One option is to spawn a process that lives independently of your main process that acts as a kind of watchdog. When it detects that your process has exited, it restores the terminal mode.