3 ms·
That is how all launched executables behave, in the terminal environment. After loaded, some executables install their own handlers for Ctrl-C. None of them ar
by quesera 4y ago
That is how all launched executables behave, in the terminal environment.
After loaded, some executables install their own handlers for Ctrl-C. None of them are copy/paste.
Emacs does nothing on a single Ctrl-C, and a double Ctrl-C evokes a "this does nothing" message. Vim prints a "how to quit" message.
I'm sure you can find an example of a terminal based program that does something less reasonable with Ctrl-C. I'm not sure you can find an example that treats Ctrl-C as copy. But you could certainly write one. You should expect people to complain if you do!
- fnordpiglet 4y agoRather I think there’s a distinction between line oriented and screen oriented. I don’t think screen oriented programs tend to honor the line mode meh bindings. When you press control-d in top do you expect it to close the terminal?
- quesera 4y agoCtrl-D means "End of transmission", which is appropriate to exit a program which expects to receive input. A process monitor like top isn't oriented toward input, particularly, so I would not expect Ctrl-D to do anything. And it does not. By the way, Ctrl-D does not close the terminal either. It tells the shell that you're finished sending input, which means it has no more work to do and should exit. If you have jobs running in the background, it will warn you first (default config). If the shell exits, and it was the only thing running in the terminal, the terminal may then decide to close itself. Some do, some do not. Back to Ctrl-C though, using your example of top as a screen-oriented program: when you press Ctrl-C in top, it interprets the input as Interrupt, and ... exits! Just like a user in a terminal environment would expect. :)
- fnordpiglet 4y agoYes, I’m aware of what it does. But do you have any screen oriented programs that treats ^D as a signal to close stdin? You are right, it does exit on ^C. I picked it as an example of something that seems compliant but doesn’t actually behave like a line oriented program as a screen oriented program.
- quesera 4y ago> But do you have any screen oriented programs that treats ^D as a signal to close stdin? stdin is a different thing in a screen-oriented program than a line-oriented one, yes. Screen-oriented typically operates on characters not strings, roughly. Closing stdin in a screen-oriented program doesn't really have a meaningful interpretation. But if you'd like an example of a screen-oriented program that exits on Ctrl-D, I can offer musikcube. Not very well-known perhaps (though it's a great music player), and to be fair I consider the Ctrl-D behavior to be a UX oddity, however harmless.