You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello - I'm having a hard time figuring out how to cleanly restore the tty state to cooked mode when my application exits. I can use a defer.Close() in the goroutine where rl.ReadLine() is running, but the problem is that sometimes my application must quit programmatically (or panics). In these cases, the program exists and leaves the terminal in a very confusing raw/noecho mode.
The only workaround I can think of is to open a pipe to a child process, which then waits for its input to close before it runs stty sane (but this won't be portable to Windows, as far as I know). And it feels like a hack...
Is there a standard idiom for this? Or some example code, perhaps?
The text was updated successfully, but these errors were encountered:
hi, it seems there has no ways to restore the tty state if it's exit unexpected.
And I can't see any terminal applications support this, even vim if I send kill -9 to it.
So, the only way is you keeping defer recover() it your every goroutines, make sure it exit properly.
Hello - I'm having a hard time figuring out how to cleanly restore the tty state to cooked mode when my application exits. I can use a
defer.Close()
in the goroutine whererl.ReadLine()
is running, but the problem is that sometimes my application must quit programmatically (or panics). In these cases, the program exists and leaves the terminal in a very confusing raw/noecho mode.The only workaround I can think of is to open a pipe to a child process, which then waits for its input to close before it runs
stty sane
(but this won't be portable to Windows, as far as I know). And it feels like a hack...Is there a standard idiom for this? Or some example code, perhaps?
The text was updated successfully, but these errors were encountered: