Skip to main content

restore

Function restore 

Source
fn restore()
Expand description

Put the terminal back. Idempotent, because Drop, the panic hook and a fatal signal can all reach it and a double panic would otherwise run it twice.

Every call in here is async-signal-safe — tcsetattr and write are on POSIX’s list, and OnceLock::get is one atomic load — because bail runs it from a signal handler. io::stdout() is the thing that would not do: taking its lock in a handler that interrupted the thread already holding it is a deadlock at exactly the moment the user wants their terminal back.