dotnet/runtime

.net 8 Console.ReadKey : Better support for return Ctrl-Z, and setting SIGSTOP

Open

#91,709 建立於 2023年9月7日

在 GitHub 查看
 (3 留言) (0 反應) (0 負責人)C# (5,445 fork)batch import
area-System.Consolehelp wanted

倉庫指標

Star
 (17,886 star)
PR 合併指標
 (平均合併 12天 11小時) (30 天內合併 661 個 PR)

描述

When a full screen / raw terminal app like vim gets a ctrl-z, it reads it as a keypress, not a signal. This can be done with the right tcsetattr() settings:

t.c_cc[Libc.VSUSP] = 0; Will stop SIGTSTP from coming as a signal, but instead it comes in as \x1A key.

But more importantly, the app then gets a chance to restore the terminal to the 'main' shell screen, before suspending itself with a SIGSTOP (I think). Basically, gracefully set the terminal back before suspending.

In .net 8, I can override the SIGTSTP (Terminal Stop) signal, and set the console back to the 'main' terminal buffer by sending a "[?1049l", but I can't send myself a SIGSTOP.

At least, not without bringing in Mono.Posix, and that seems to have additional complications with AOT compilation. (Missing DLL)

Ideally, .net knows how to gracefully suspend a console app -- taking it away from and back to the alternate terminal screen -- without additional libraries.

貢獻者指南